From bded80a51416423c1baa114dc390c7e19b098cdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Barroso?= Date: Tue, 6 Apr 2021 15:03:42 +0200 Subject: [PATCH] =?UTF-8?q?feat(cli):=20Add=20=E2=80=94debug=20flag=20(#10?= =?UTF-8?q?8)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/client.go | 9 ++------- cmd/root.go | 20 ++++++++++---------- cmd/root_test.go | 1 + docs/cmd/meroxa.md | 1 + docs/cmd/meroxa_add.md | 1 + docs/cmd/meroxa_add_resource.md | 1 + docs/cmd/meroxa_api.md | 1 + docs/cmd/meroxa_billing.md | 1 + docs/cmd/meroxa_completion.md | 1 + docs/cmd/meroxa_connect.md | 1 + docs/cmd/meroxa_create.md | 1 + docs/cmd/meroxa_create_connector.md | 1 + docs/cmd/meroxa_create_endpoint.md | 1 + docs/cmd/meroxa_create_pipeline.md | 1 + docs/cmd/meroxa_describe.md | 1 + docs/cmd/meroxa_describe_connector.md | 1 + docs/cmd/meroxa_describe_endpoint.md | 1 + docs/cmd/meroxa_describe_resource.md | 1 + docs/cmd/meroxa_list.md | 1 + docs/cmd/meroxa_list_connectors.md | 1 + docs/cmd/meroxa_list_endpoint.md | 1 + docs/cmd/meroxa_list_pipelines.md | 1 + docs/cmd/meroxa_list_resource-types.md | 1 + docs/cmd/meroxa_list_resources.md | 1 + docs/cmd/meroxa_list_transforms.md | 1 + docs/cmd/meroxa_login.md | 1 + docs/cmd/meroxa_logout.md | 1 + docs/cmd/meroxa_logs.md | 1 + docs/cmd/meroxa_logs_connector.md | 1 + docs/cmd/meroxa_open.md | 1 + docs/cmd/meroxa_open_billing.md | 1 + docs/cmd/meroxa_remove.md | 1 + docs/cmd/meroxa_remove_connector.md | 1 + docs/cmd/meroxa_remove_endpoint.md | 1 + docs/cmd/meroxa_remove_pipeline.md | 1 + docs/cmd/meroxa_remove_resource.md | 1 + docs/cmd/meroxa_update.md | 1 + docs/cmd/meroxa_update_connector.md | 1 + docs/cmd/meroxa_update_pipeline.md | 1 + docs/cmd/meroxa_update_resource.md | 1 + docs/cmd/meroxa_version.md | 1 + 41 files changed, 51 insertions(+), 17 deletions(-) diff --git a/cmd/client.go b/cmd/client.go index 402dc6544..859e869b9 100644 --- a/cmd/client.go +++ b/cmd/client.go @@ -116,13 +116,8 @@ func getAccessToken() (string, error) { } func isDebugEnabled() bool { - if val, ok := os.LookupEnv("MEROXA_DEBUG"); ok { - if val == "1" { - return true - } - } - - return false + val, ok := os.LookupEnv("MEROXA_DEBUG") + return flagDebug || (ok && val == "1") } func client() (*meroxa.Client, error) { diff --git a/cmd/root.go b/cmd/root.go index d28e9e4c7..1caf6e88e 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -39,13 +39,13 @@ const ( ) var ( - meroxaVersion string - cfgFile string - source string - destination string - flagRootOutputJSON bool - meroxaCmd *cobra.Command - cfg *viper.Viper + meroxaVersion string + cfgFile string + source string + destination string + flagRootOutputJSON, flagDebug bool + meroxaCmd *cobra.Command + cfg *viper.Viper ) // RootCmd represents the base command when called without any subcommands @@ -69,6 +69,8 @@ meroxa list resource-types`, rootCmd.PersistentFlags().BoolVar(&flagRootOutputJSON, "json", false, "output json") rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/meroxa.env)") + rootCmd.PersistentFlags().BoolVar(&flagDebug, "debug", false, "display any debugging information") + rootCmd.SilenceUsage = true rootCmd.DisableAutoGenTag = true @@ -85,9 +87,7 @@ meroxa list resource-types`, rootCmd.AddCommand(LogoutCmd()) rootCmd.AddCommand(LogsCmd()) rootCmd.AddCommand(OpenCmd()) - - r := &Remove{} - rootCmd.AddCommand(r.command()) + rootCmd.AddCommand((&Remove{}).command()) rootCmd.AddCommand(UpdateCmd()) rootCmd.AddCommand(VersionCmd()) diff --git a/cmd/root_test.go b/cmd/root_test.go index 0487f5705..7e828b630 100644 --- a/cmd/root_test.go +++ b/cmd/root_test.go @@ -36,6 +36,7 @@ func TestRootCmd(t *testing.T) { {"version Display the Meroxa CLI version"}, {"Flags:\n" + " --config string config file (default is $HOME/meroxa.env)\n" + + " --debug display any debugging information\n" + " -h, --help help for meroxa\n" + " --json output json\n\n"}, {"Use \"meroxa [command] --help\" for more information about a command."}, diff --git a/docs/cmd/meroxa.md b/docs/cmd/meroxa.md index d2702b65c..21d164742 100644 --- a/docs/cmd/meroxa.md +++ b/docs/cmd/meroxa.md @@ -16,6 +16,7 @@ meroxa list resource-types ``` --config string config file (default is $HOME/meroxa.env) + --debug display any debugging information -h, --help help for meroxa --json output json ``` diff --git a/docs/cmd/meroxa_add.md b/docs/cmd/meroxa_add.md index 76fb14f00..28bb6e50a 100644 --- a/docs/cmd/meroxa_add.md +++ b/docs/cmd/meroxa_add.md @@ -12,6 +12,7 @@ Add a resource to your Meroxa resource catalog ``` --config string config file (default is $HOME/meroxa.env) + --debug display any debugging information --json output json ``` diff --git a/docs/cmd/meroxa_add_resource.md b/docs/cmd/meroxa_add_resource.md index 1dbf796cd..7e1058984 100644 --- a/docs/cmd/meroxa_add_resource.md +++ b/docs/cmd/meroxa_add_resource.md @@ -35,6 +35,7 @@ meroxa add resource slack --type url -u $WEBHOOK_URL ``` --config string config file (default is $HOME/meroxa.env) + --debug display any debugging information --json output json ``` diff --git a/docs/cmd/meroxa_api.md b/docs/cmd/meroxa_api.md index fc58dd066..d60a83022 100644 --- a/docs/cmd/meroxa_api.md +++ b/docs/cmd/meroxa_api.md @@ -24,6 +24,7 @@ meroxa api POST /v1/endpoints '{"protocol": "HTTP", "stream": "resource-2-499379 ``` --config string config file (default is $HOME/meroxa.env) + --debug display any debugging information --json output json ``` diff --git a/docs/cmd/meroxa_billing.md b/docs/cmd/meroxa_billing.md index f8a58e3b3..9bc8ef63f 100644 --- a/docs/cmd/meroxa_billing.md +++ b/docs/cmd/meroxa_billing.md @@ -16,6 +16,7 @@ meroxa billing [flags] ``` --config string config file (default is $HOME/meroxa.env) + --debug display any debugging information --json output json ``` diff --git a/docs/cmd/meroxa_completion.md b/docs/cmd/meroxa_completion.md index b9d760edc..ef8000519 100644 --- a/docs/cmd/meroxa_completion.md +++ b/docs/cmd/meroxa_completion.md @@ -50,6 +50,7 @@ meroxa completion [bash|zsh|fish|powershell] ``` --config string config file (default is $HOME/meroxa.env) + --debug display any debugging information --json output json ``` diff --git a/docs/cmd/meroxa_connect.md b/docs/cmd/meroxa_connect.md index 58afc13eb..9a679c45c 100644 --- a/docs/cmd/meroxa_connect.md +++ b/docs/cmd/meroxa_connect.md @@ -35,6 +35,7 @@ meroxa connect --from --to [flags] ``` --config string config file (default is $HOME/meroxa.env) + --debug display any debugging information --json output json ``` diff --git a/docs/cmd/meroxa_create.md b/docs/cmd/meroxa_create.md index 7a29a250c..ee2dbf540 100644 --- a/docs/cmd/meroxa_create.md +++ b/docs/cmd/meroxa_create.md @@ -17,6 +17,7 @@ including connectors. ``` --config string config file (default is $HOME/meroxa.env) + --debug display any debugging information --json output json ``` diff --git a/docs/cmd/meroxa_create_connector.md b/docs/cmd/meroxa_create_connector.md index ef134f062..a29787a9e 100644 --- a/docs/cmd/meroxa_create_connector.md +++ b/docs/cmd/meroxa_create_connector.md @@ -31,6 +31,7 @@ meroxa create connector [] --to pg2redshift --input order ``` --config string config file (default is $HOME/meroxa.env) + --debug display any debugging information --json output json ``` diff --git a/docs/cmd/meroxa_create_endpoint.md b/docs/cmd/meroxa_create_endpoint.md index 7e3d24d2e..92cc6a7d8 100644 --- a/docs/cmd/meroxa_create_endpoint.md +++ b/docs/cmd/meroxa_create_endpoint.md @@ -29,6 +29,7 @@ meroxa create endpoint my-endpoint --protocol http --stream my-stream ``` --config string config file (default is $HOME/meroxa.env) + --debug display any debugging information --json output json ``` diff --git a/docs/cmd/meroxa_create_pipeline.md b/docs/cmd/meroxa_create_pipeline.md index 96a1cf2e4..416f95082 100644 --- a/docs/cmd/meroxa_create_pipeline.md +++ b/docs/cmd/meroxa_create_pipeline.md @@ -17,6 +17,7 @@ meroxa create pipeline [flags] ``` --config string config file (default is $HOME/meroxa.env) + --debug display any debugging information --json output json ``` diff --git a/docs/cmd/meroxa_describe.md b/docs/cmd/meroxa_describe.md index 94d26b332..f2468b9f9 100644 --- a/docs/cmd/meroxa_describe.md +++ b/docs/cmd/meroxa_describe.md @@ -16,6 +16,7 @@ Describe a component of the Meroxa data platform, including resources and connec ``` --config string config file (default is $HOME/meroxa.env) + --debug display any debugging information --json output json ``` diff --git a/docs/cmd/meroxa_describe_connector.md b/docs/cmd/meroxa_describe_connector.md index 77f1b7962..f7a6c1b72 100644 --- a/docs/cmd/meroxa_describe_connector.md +++ b/docs/cmd/meroxa_describe_connector.md @@ -16,6 +16,7 @@ meroxa describe connector [name] [flags] ``` --config string config file (default is $HOME/meroxa.env) + --debug display any debugging information --json output json ``` diff --git a/docs/cmd/meroxa_describe_endpoint.md b/docs/cmd/meroxa_describe_endpoint.md index e9a07aa46..1ffe34f0f 100644 --- a/docs/cmd/meroxa_describe_endpoint.md +++ b/docs/cmd/meroxa_describe_endpoint.md @@ -16,6 +16,7 @@ meroxa describe endpoint [flags] ``` --config string config file (default is $HOME/meroxa.env) + --debug display any debugging information --json output json ``` diff --git a/docs/cmd/meroxa_describe_resource.md b/docs/cmd/meroxa_describe_resource.md index 8a4a7a2dc..726694fbc 100644 --- a/docs/cmd/meroxa_describe_resource.md +++ b/docs/cmd/meroxa_describe_resource.md @@ -16,6 +16,7 @@ meroxa describe resource [flags] ``` --config string config file (default is $HOME/meroxa.env) + --debug display any debugging information --json output json ``` diff --git a/docs/cmd/meroxa_list.md b/docs/cmd/meroxa_list.md index f7a4d8789..bd26d426b 100644 --- a/docs/cmd/meroxa_list.md +++ b/docs/cmd/meroxa_list.md @@ -17,6 +17,7 @@ List the components of the Meroxa platform, including pipelines, ``` --config string config file (default is $HOME/meroxa.env) + --debug display any debugging information --json output json ``` diff --git a/docs/cmd/meroxa_list_connectors.md b/docs/cmd/meroxa_list_connectors.md index 1e42ded7e..6287cbb38 100644 --- a/docs/cmd/meroxa_list_connectors.md +++ b/docs/cmd/meroxa_list_connectors.md @@ -16,6 +16,7 @@ meroxa list connectors [flags] ``` --config string config file (default is $HOME/meroxa.env) + --debug display any debugging information --json output json ``` diff --git a/docs/cmd/meroxa_list_endpoint.md b/docs/cmd/meroxa_list_endpoint.md index 0fb8f18f0..f4630ebbb 100644 --- a/docs/cmd/meroxa_list_endpoint.md +++ b/docs/cmd/meroxa_list_endpoint.md @@ -16,6 +16,7 @@ meroxa list endpoint [flags] ``` --config string config file (default is $HOME/meroxa.env) + --debug display any debugging information --json output json ``` diff --git a/docs/cmd/meroxa_list_pipelines.md b/docs/cmd/meroxa_list_pipelines.md index 5504c78ad..2b64b78fc 100644 --- a/docs/cmd/meroxa_list_pipelines.md +++ b/docs/cmd/meroxa_list_pipelines.md @@ -16,6 +16,7 @@ meroxa list pipelines [flags] ``` --config string config file (default is $HOME/meroxa.env) + --debug display any debugging information --json output json ``` diff --git a/docs/cmd/meroxa_list_resource-types.md b/docs/cmd/meroxa_list_resource-types.md index 806cbb08c..a5923b3ec 100644 --- a/docs/cmd/meroxa_list_resource-types.md +++ b/docs/cmd/meroxa_list_resource-types.md @@ -16,6 +16,7 @@ meroxa list resource-types [flags] ``` --config string config file (default is $HOME/meroxa.env) + --debug display any debugging information --json output json ``` diff --git a/docs/cmd/meroxa_list_resources.md b/docs/cmd/meroxa_list_resources.md index 71dd2823c..608b896f0 100644 --- a/docs/cmd/meroxa_list_resources.md +++ b/docs/cmd/meroxa_list_resources.md @@ -16,6 +16,7 @@ meroxa list resources [flags] ``` --config string config file (default is $HOME/meroxa.env) + --debug display any debugging information --json output json ``` diff --git a/docs/cmd/meroxa_list_transforms.md b/docs/cmd/meroxa_list_transforms.md index 19e8a8cae..6221b9a32 100644 --- a/docs/cmd/meroxa_list_transforms.md +++ b/docs/cmd/meroxa_list_transforms.md @@ -16,6 +16,7 @@ meroxa list transforms [flags] ``` --config string config file (default is $HOME/meroxa.env) + --debug display any debugging information --json output json ``` diff --git a/docs/cmd/meroxa_login.md b/docs/cmd/meroxa_login.md index cb62d2366..726764306 100644 --- a/docs/cmd/meroxa_login.md +++ b/docs/cmd/meroxa_login.md @@ -16,6 +16,7 @@ meroxa login [flags] ``` --config string config file (default is $HOME/meroxa.env) + --debug display any debugging information --json output json ``` diff --git a/docs/cmd/meroxa_logout.md b/docs/cmd/meroxa_logout.md index de0877e97..b95782c5a 100644 --- a/docs/cmd/meroxa_logout.md +++ b/docs/cmd/meroxa_logout.md @@ -16,6 +16,7 @@ meroxa logout [flags] ``` --config string config file (default is $HOME/meroxa.env) + --debug display any debugging information --json output json ``` diff --git a/docs/cmd/meroxa_logs.md b/docs/cmd/meroxa_logs.md index 7e6abc83f..582191524 100644 --- a/docs/cmd/meroxa_logs.md +++ b/docs/cmd/meroxa_logs.md @@ -12,6 +12,7 @@ Print logs for a component ``` --config string config file (default is $HOME/meroxa.env) + --debug display any debugging information --json output json ``` diff --git a/docs/cmd/meroxa_logs_connector.md b/docs/cmd/meroxa_logs_connector.md index 21b5dfc83..243246100 100644 --- a/docs/cmd/meroxa_logs_connector.md +++ b/docs/cmd/meroxa_logs_connector.md @@ -16,6 +16,7 @@ meroxa logs connector [flags] ``` --config string config file (default is $HOME/meroxa.env) + --debug display any debugging information --json output json ``` diff --git a/docs/cmd/meroxa_open.md b/docs/cmd/meroxa_open.md index eee10f2ca..1392db210 100644 --- a/docs/cmd/meroxa_open.md +++ b/docs/cmd/meroxa_open.md @@ -12,6 +12,7 @@ Open in a web browser ``` --config string config file (default is $HOME/meroxa.env) + --debug display any debugging information --json output json ``` diff --git a/docs/cmd/meroxa_open_billing.md b/docs/cmd/meroxa_open_billing.md index 012870b9b..a61badad6 100644 --- a/docs/cmd/meroxa_open_billing.md +++ b/docs/cmd/meroxa_open_billing.md @@ -16,6 +16,7 @@ meroxa open billing [flags] ``` --config string config file (default is $HOME/meroxa.env) + --debug display any debugging information --json output json ``` diff --git a/docs/cmd/meroxa_remove.md b/docs/cmd/meroxa_remove.md index 6cf478a66..500a12b28 100644 --- a/docs/cmd/meroxa_remove.md +++ b/docs/cmd/meroxa_remove.md @@ -18,6 +18,7 @@ Deprovision a component of the Meroxa platform, including pipelines, ``` --config string config file (default is $HOME/meroxa.env) + --debug display any debugging information --json output json ``` diff --git a/docs/cmd/meroxa_remove_connector.md b/docs/cmd/meroxa_remove_connector.md index 19d36f2e9..c48d92886 100644 --- a/docs/cmd/meroxa_remove_connector.md +++ b/docs/cmd/meroxa_remove_connector.md @@ -16,6 +16,7 @@ meroxa remove connector [flags] ``` --config string config file (default is $HOME/meroxa.env) + --debug display any debugging information -f, --force force delete without confirmation prompt --json output json ``` diff --git a/docs/cmd/meroxa_remove_endpoint.md b/docs/cmd/meroxa_remove_endpoint.md index f540b0cf0..2fd375eaf 100644 --- a/docs/cmd/meroxa_remove_endpoint.md +++ b/docs/cmd/meroxa_remove_endpoint.md @@ -16,6 +16,7 @@ meroxa remove endpoint [flags] ``` --config string config file (default is $HOME/meroxa.env) + --debug display any debugging information -f, --force force delete without confirmation prompt --json output json ``` diff --git a/docs/cmd/meroxa_remove_pipeline.md b/docs/cmd/meroxa_remove_pipeline.md index 2189b8566..a124dda75 100644 --- a/docs/cmd/meroxa_remove_pipeline.md +++ b/docs/cmd/meroxa_remove_pipeline.md @@ -16,6 +16,7 @@ meroxa remove pipeline [flags] ``` --config string config file (default is $HOME/meroxa.env) + --debug display any debugging information -f, --force force delete without confirmation prompt --json output json ``` diff --git a/docs/cmd/meroxa_remove_resource.md b/docs/cmd/meroxa_remove_resource.md index ab6819b45..1fc723be0 100644 --- a/docs/cmd/meroxa_remove_resource.md +++ b/docs/cmd/meroxa_remove_resource.md @@ -16,6 +16,7 @@ meroxa remove resource [flags] ``` --config string config file (default is $HOME/meroxa.env) + --debug display any debugging information -f, --force force delete without confirmation prompt --json output json ``` diff --git a/docs/cmd/meroxa_update.md b/docs/cmd/meroxa_update.md index 03a62e9ad..5442fa0d5 100644 --- a/docs/cmd/meroxa_update.md +++ b/docs/cmd/meroxa_update.md @@ -16,6 +16,7 @@ Update a component of the Meroxa platform, including connectors ``` --config string config file (default is $HOME/meroxa.env) + --debug display any debugging information --json output json ``` diff --git a/docs/cmd/meroxa_update_connector.md b/docs/cmd/meroxa_update_connector.md index 65b35115f..0758d0558 100644 --- a/docs/cmd/meroxa_update_connector.md +++ b/docs/cmd/meroxa_update_connector.md @@ -17,6 +17,7 @@ meroxa update connector --state [flags] ``` --config string config file (default is $HOME/meroxa.env) + --debug display any debugging information --json output json ``` diff --git a/docs/cmd/meroxa_update_pipeline.md b/docs/cmd/meroxa_update_pipeline.md index 8ac4c97bd..0b3ed49d7 100644 --- a/docs/cmd/meroxa_update_pipeline.md +++ b/docs/cmd/meroxa_update_pipeline.md @@ -28,6 +28,7 @@ meroxa update pipeline pipeline-name --metadata '{"key":"value"}' ``` --config string config file (default is $HOME/meroxa.env) + --debug display any debugging information --json output json ``` diff --git a/docs/cmd/meroxa_update_resource.md b/docs/cmd/meroxa_update_resource.md index 7bd891859..3e5947169 100644 --- a/docs/cmd/meroxa_update_resource.md +++ b/docs/cmd/meroxa_update_resource.md @@ -23,6 +23,7 @@ meroxa update resource [flags] ``` --config string config file (default is $HOME/meroxa.env) + --debug display any debugging information --json output json ``` diff --git a/docs/cmd/meroxa_version.md b/docs/cmd/meroxa_version.md index 5819d4fd1..2f003c280 100644 --- a/docs/cmd/meroxa_version.md +++ b/docs/cmd/meroxa_version.md @@ -16,6 +16,7 @@ meroxa version [flags] ``` --config string config file (default is $HOME/meroxa.env) + --debug display any debugging information --json output json ```