Skip to content

Commit

Permalink
feat(cli): Add —debug flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Raúl Barroso committed Apr 6, 2021
1 parent 6db183e commit a60a0ae
Show file tree
Hide file tree
Showing 41 changed files with 51 additions and 17 deletions.
9 changes: 2 additions & 7 deletions cmd/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
20 changes: 10 additions & 10 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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())

Expand Down
1 change: 1 addition & 0 deletions cmd/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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."},
Expand Down
1 change: 1 addition & 0 deletions docs/cmd/meroxa.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand Down
1 change: 1 addition & 0 deletions docs/cmd/meroxa_add.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down
1 change: 1 addition & 0 deletions docs/cmd/meroxa_add_resource.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down
1 change: 1 addition & 0 deletions docs/cmd/meroxa_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down
1 change: 1 addition & 0 deletions docs/cmd/meroxa_billing.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ meroxa billing [flags]

```
--config string config file (default is $HOME/meroxa.env)
--debug display any debugging information
--json output json
```

Expand Down
1 change: 1 addition & 0 deletions docs/cmd/meroxa_completion.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down
1 change: 1 addition & 0 deletions docs/cmd/meroxa_connect.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ meroxa connect --from <resource-name> --to <resource-name> [flags]

```
--config string config file (default is $HOME/meroxa.env)
--debug display any debugging information
--json output json
```

Expand Down
1 change: 1 addition & 0 deletions docs/cmd/meroxa_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ including connectors.

```
--config string config file (default is $HOME/meroxa.env)
--debug display any debugging information
--json output json
```

Expand Down
1 change: 1 addition & 0 deletions docs/cmd/meroxa_create_connector.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ meroxa create connector [<custom-connector-name>] --to pg2redshift --input order

```
--config string config file (default is $HOME/meroxa.env)
--debug display any debugging information
--json output json
```

Expand Down
1 change: 1 addition & 0 deletions docs/cmd/meroxa_create_endpoint.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down
1 change: 1 addition & 0 deletions docs/cmd/meroxa_create_pipeline.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ meroxa create pipeline <name> [flags]

```
--config string config file (default is $HOME/meroxa.env)
--debug display any debugging information
--json output json
```

Expand Down
1 change: 1 addition & 0 deletions docs/cmd/meroxa_describe.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down
1 change: 1 addition & 0 deletions docs/cmd/meroxa_describe_connector.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down
1 change: 1 addition & 0 deletions docs/cmd/meroxa_describe_endpoint.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ meroxa describe endpoint <name> [flags]

```
--config string config file (default is $HOME/meroxa.env)
--debug display any debugging information
--json output json
```

Expand Down
1 change: 1 addition & 0 deletions docs/cmd/meroxa_describe_resource.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ meroxa describe resource <name> [flags]

```
--config string config file (default is $HOME/meroxa.env)
--debug display any debugging information
--json output json
```

Expand Down
1 change: 1 addition & 0 deletions docs/cmd/meroxa_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down
1 change: 1 addition & 0 deletions docs/cmd/meroxa_list_connectors.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down
1 change: 1 addition & 0 deletions docs/cmd/meroxa_list_endpoint.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down
1 change: 1 addition & 0 deletions docs/cmd/meroxa_list_pipelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down
1 change: 1 addition & 0 deletions docs/cmd/meroxa_list_resource-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down
1 change: 1 addition & 0 deletions docs/cmd/meroxa_list_resources.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down
1 change: 1 addition & 0 deletions docs/cmd/meroxa_list_transforms.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down
1 change: 1 addition & 0 deletions docs/cmd/meroxa_login.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ meroxa login [flags]

```
--config string config file (default is $HOME/meroxa.env)
--debug display any debugging information
--json output json
```

Expand Down
1 change: 1 addition & 0 deletions docs/cmd/meroxa_logout.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ meroxa logout [flags]

```
--config string config file (default is $HOME/meroxa.env)
--debug display any debugging information
--json output json
```

Expand Down
1 change: 1 addition & 0 deletions docs/cmd/meroxa_logs.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down
1 change: 1 addition & 0 deletions docs/cmd/meroxa_logs_connector.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ meroxa logs connector <name> [flags]

```
--config string config file (default is $HOME/meroxa.env)
--debug display any debugging information
--json output json
```

Expand Down
1 change: 1 addition & 0 deletions docs/cmd/meroxa_open.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down
1 change: 1 addition & 0 deletions docs/cmd/meroxa_open_billing.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down
1 change: 1 addition & 0 deletions docs/cmd/meroxa_remove.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down
1 change: 1 addition & 0 deletions docs/cmd/meroxa_remove_connector.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ meroxa remove connector <name> [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
```
Expand Down
1 change: 1 addition & 0 deletions docs/cmd/meroxa_remove_endpoint.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ meroxa remove endpoint <name> [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
```
Expand Down
1 change: 1 addition & 0 deletions docs/cmd/meroxa_remove_pipeline.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ meroxa remove pipeline <name> [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
```
Expand Down
1 change: 1 addition & 0 deletions docs/cmd/meroxa_remove_resource.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ meroxa remove resource <name> [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
```
Expand Down
1 change: 1 addition & 0 deletions docs/cmd/meroxa_update.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down
1 change: 1 addition & 0 deletions docs/cmd/meroxa_update_connector.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ meroxa update connector <name> --state <pause|resume|restart> [flags]

```
--config string config file (default is $HOME/meroxa.env)
--debug display any debugging information
--json output json
```

Expand Down
1 change: 1 addition & 0 deletions docs/cmd/meroxa_update_pipeline.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down
1 change: 1 addition & 0 deletions docs/cmd/meroxa_update_resource.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ meroxa update resource <resource-name> [flags]

```
--config string config file (default is $HOME/meroxa.env)
--debug display any debugging information
--json output json
```

Expand Down
1 change: 1 addition & 0 deletions docs/cmd/meroxa_version.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ meroxa version [flags]

```
--config string config file (default is $HOME/meroxa.env)
--debug display any debugging information
--json output json
```

Expand Down

0 comments on commit a60a0ae

Please sign in to comment.