Skip to content

Commit

Permalink
fix: Collision with --global flags (#194)
Browse files Browse the repository at this point in the history
Meroxa CLI used it before to specify the path of a configuration file, while connectors still use it the same as well.
  • Loading branch information
raulb authored Sep 29, 2021
1 parent ac1587b commit e8c3e26
Show file tree
Hide file tree
Showing 135 changed files with 564 additions and 556 deletions.
4 changes: 2 additions & 2 deletions cmd/meroxa/global/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ func getEnvVal(keys []string, defaultVal string) string {
func readConfig() (*viper.Viper, error) {
cfg := viper.New()

if flagConfig != "" {
if flagCLIConfigFile != "" {
// Use config file from the flag.
cfg.SetConfigFile(flagConfig)
cfg.SetConfigFile(flagCLIConfigFile)
} else {
// Find home directory.
configDir, err := os.UserConfigDir()
Expand Down
20 changes: 14 additions & 6 deletions cmd/meroxa/global/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ var (
)

var (
flagConfig string
flagAPIURL string
flagDebug bool
flagTimeout time.Duration
flagJSON bool
flagCLIConfigFile string
flagAPIURL string
flagDebug bool
flagTimeout time.Duration
flagJSON bool
)

func DeprecateV1Commands() bool {
Expand All @@ -44,14 +44,22 @@ func DeprecateV1Commands() bool {

func RegisterGlobalFlags(cmd *cobra.Command) {
cmd.PersistentFlags().BoolVar(&flagJSON, "json", false, "output json")
cmd.PersistentFlags().StringVar(&flagConfig, "config", "", "config file")

// It stays around until we update our acceptance tests
cmd.PersistentFlags().StringVar(&flagCLIConfigFile, "config", "", "meroxa configuration file")

cmd.PersistentFlags().StringVar(&flagCLIConfigFile, "cli-config-file", "", "meroxa configuration file")
cmd.PersistentFlags().StringVar(&flagAPIURL, "api-url", "", "API url")
cmd.PersistentFlags().BoolVar(&flagDebug, "debug", false, "display any debugging information")
cmd.PersistentFlags().DurationVar(&flagTimeout, "timeout", time.Second*10, "set the duration of the client timeout in seconds (default 10s)") // nolint:gomnd,lll

if err := cmd.PersistentFlags().MarkHidden("api-url"); err != nil {
panic(fmt.Sprintf("could not mark flag as hidden: %v", err))
}

if err := cmd.PersistentFlags().MarkHidden("config"); err != nil {
panic(fmt.Sprintf("could not mark flag as hidden: %v", err))
}
}

func PersistentPreRunE(cmd *cobra.Command) error {
Expand Down
10 changes: 5 additions & 5 deletions docs/cmd/md/meroxa.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ meroxa resources list --types
### Options

```
--config string config file
--debug display any debugging information
-h, --help help for meroxa
--json output json
--timeout duration set the duration of the client timeout in seconds (default 10s) (default 10s)
--cli-config-file string meroxa configuration file
--debug display any debugging information
-h, --help help for meroxa
--json output json
--timeout duration set the duration of the client timeout in seconds (default 10s) (default 10s)
```

### SEE ALSO
Expand Down
8 changes: 4 additions & 4 deletions docs/cmd/md/meroxa_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ meroxa api POST /v1/endpoints '{"protocol": "HTTP", "stream": "resource-2-499379
### Options inherited from parent commands

```
--config string config file
--debug display any debugging information
--json output json
--timeout duration set the duration of the client timeout in seconds (default 10s) (default 10s)
--cli-config-file string meroxa configuration file
--debug display any debugging information
--json output json
--timeout duration set the duration of the client timeout in seconds (default 10s) (default 10s)
```

### SEE ALSO
Expand Down
8 changes: 4 additions & 4 deletions docs/cmd/md/meroxa_auth.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ Authentication commands for Meroxa
### Options inherited from parent commands

```
--config string config file
--debug display any debugging information
--json output json
--timeout duration set the duration of the client timeout in seconds (default 10s) (default 10s)
--cli-config-file string meroxa configuration file
--debug display any debugging information
--json output json
--timeout duration set the duration of the client timeout in seconds (default 10s) (default 10s)
```

### SEE ALSO
Expand Down
8 changes: 4 additions & 4 deletions docs/cmd/md/meroxa_auth_login.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ meroxa auth login [flags]
### Options inherited from parent commands

```
--config string config file
--debug display any debugging information
--json output json
--timeout duration set the duration of the client timeout in seconds (default 10s) (default 10s)
--cli-config-file string meroxa configuration file
--debug display any debugging information
--json output json
--timeout duration set the duration of the client timeout in seconds (default 10s) (default 10s)
```

### SEE ALSO
Expand Down
8 changes: 4 additions & 4 deletions docs/cmd/md/meroxa_auth_logout.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ meroxa auth logout [flags]
### Options inherited from parent commands

```
--config string config file
--debug display any debugging information
--json output json
--timeout duration set the duration of the client timeout in seconds (default 10s) (default 10s)
--cli-config-file string meroxa configuration file
--debug display any debugging information
--json output json
--timeout duration set the duration of the client timeout in seconds (default 10s) (default 10s)
```

### SEE ALSO
Expand Down
8 changes: 4 additions & 4 deletions docs/cmd/md/meroxa_auth_whoami.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ meroxa whoami
### Options inherited from parent commands

```
--config string config file
--debug display any debugging information
--json output json
--timeout duration set the duration of the client timeout in seconds (default 10s) (default 10s)
--cli-config-file string meroxa configuration file
--debug display any debugging information
--json output json
--timeout duration set the duration of the client timeout in seconds (default 10s) (default 10s)
```

### SEE ALSO
Expand Down
8 changes: 4 additions & 4 deletions docs/cmd/md/meroxa_billing.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ meroxa billing [flags]
### Options inherited from parent commands

```
--config string config file
--debug display any debugging information
--json output json
--timeout duration set the duration of the client timeout in seconds (default 10s) (default 10s)
--cli-config-file string meroxa configuration file
--debug display any debugging information
--json output json
--timeout duration set the duration of the client timeout in seconds (default 10s) (default 10s)
```

### SEE ALSO
Expand Down
8 changes: 4 additions & 4 deletions docs/cmd/md/meroxa_completion.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ meroxa completion [bash|zsh|fish|powershell]
### Options inherited from parent commands

```
--config string config file
--debug display any debugging information
--json output json
--timeout duration set the duration of the client timeout in seconds (default 10s) (default 10s)
--cli-config-file string meroxa configuration file
--debug display any debugging information
--json output json
--timeout duration set the duration of the client timeout in seconds (default 10s) (default 10s)
```

### SEE ALSO
Expand Down
8 changes: 4 additions & 4 deletions docs/cmd/md/meroxa_config.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ meroxa config [flags]
### Options inherited from parent commands

```
--config string config file
--debug display any debugging information
--json output json
--timeout duration set the duration of the client timeout in seconds (default 10s) (default 10s)
--cli-config-file string meroxa configuration file
--debug display any debugging information
--json output json
--timeout duration set the duration of the client timeout in seconds (default 10s) (default 10s)
```

### SEE ALSO
Expand Down
8 changes: 4 additions & 4 deletions docs/cmd/md/meroxa_config_describe.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ refresh_token: c337a0d...c0f928b
### Options inherited from parent commands

```
--config string config file
--debug display any debugging information
--json output json
--timeout duration set the duration of the client timeout in seconds (default 10s) (default 10s)
--cli-config-file string meroxa configuration file
--debug display any debugging information
--json output json
--timeout duration set the duration of the client timeout in seconds (default 10s) (default 10s)
```

### SEE ALSO
Expand Down
8 changes: 4 additions & 4 deletions docs/cmd/md/meroxa_connect.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ meroxa connect --from RESOURCE-NAME --to RESOURCE-NAME [flags]
### Options inherited from parent commands

```
--config string config file
--debug display any debugging information
--json output json
--timeout duration set the duration of the client timeout in seconds (default 10s) (default 10s)
--cli-config-file string meroxa configuration file
--debug display any debugging information
--json output json
--timeout duration set the duration of the client timeout in seconds (default 10s) (default 10s)
```

### SEE ALSO
Expand Down
8 changes: 4 additions & 4 deletions docs/cmd/md/meroxa_connectors.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ Manage connectors on Meroxa
### Options inherited from parent commands

```
--config string config file
--debug display any debugging information
--json output json
--timeout duration set the duration of the client timeout in seconds (default 10s) (default 10s)
--cli-config-file string meroxa configuration file
--debug display any debugging information
--json output json
--timeout duration set the duration of the client timeout in seconds (default 10s) (default 10s)
```

### SEE ALSO
Expand Down
8 changes: 4 additions & 4 deletions docs/cmd/md/meroxa_connectors_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ meroxa connectors create [NAME] --to pg2redshift --input orders --pipeline my-pi
### Options inherited from parent commands

```
--config string config file
--debug display any debugging information
--json output json
--timeout duration set the duration of the client timeout in seconds (default 10s) (default 10s)
--cli-config-file string meroxa configuration file
--debug display any debugging information
--json output json
--timeout duration set the duration of the client timeout in seconds (default 10s) (default 10s)
```

### SEE ALSO
Expand Down
8 changes: 4 additions & 4 deletions docs/cmd/md/meroxa_connectors_describe.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ meroxa connectors describe [NAME] [flags]
### Options inherited from parent commands

```
--config string config file
--debug display any debugging information
--json output json
--timeout duration set the duration of the client timeout in seconds (default 10s) (default 10s)
--cli-config-file string meroxa configuration file
--debug display any debugging information
--json output json
--timeout duration set the duration of the client timeout in seconds (default 10s) (default 10s)
```

### SEE ALSO
Expand Down
8 changes: 4 additions & 4 deletions docs/cmd/md/meroxa_connectors_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ meroxa connectors list [flags]
### Options inherited from parent commands

```
--config string config file
--debug display any debugging information
--json output json
--timeout duration set the duration of the client timeout in seconds (default 10s) (default 10s)
--cli-config-file string meroxa configuration file
--debug display any debugging information
--json output json
--timeout duration set the duration of the client timeout in seconds (default 10s) (default 10s)
```

### SEE ALSO
Expand Down
8 changes: 4 additions & 4 deletions docs/cmd/md/meroxa_connectors_logs.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ meroxa connectors logs NAME [flags]
### Options inherited from parent commands

```
--config string config file
--debug display any debugging information
--json output json
--timeout duration set the duration of the client timeout in seconds (default 10s) (default 10s)
--cli-config-file string meroxa configuration file
--debug display any debugging information
--json output json
--timeout duration set the duration of the client timeout in seconds (default 10s) (default 10s)
```

### SEE ALSO
Expand Down
8 changes: 4 additions & 4 deletions docs/cmd/md/meroxa_connectors_remove.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ meroxa connectors remove NAME [flags]
### Options inherited from parent commands

```
--config string config file
--debug display any debugging information
--json output json
--timeout duration set the duration of the client timeout in seconds (default 10s) (default 10s)
--cli-config-file string meroxa configuration file
--debug display any debugging information
--json output json
--timeout duration set the duration of the client timeout in seconds (default 10s) (default 10s)
```

### SEE ALSO
Expand Down
8 changes: 4 additions & 4 deletions docs/cmd/md/meroxa_connectors_update.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ meroxa connector update connector-name --config '{"table.name.format":"public.co
### Options inherited from parent commands

```
--config string config file
--debug display any debugging information
--json output json
--timeout duration set the duration of the client timeout in seconds (default 10s) (default 10s)
--cli-config-file string meroxa configuration file
--debug display any debugging information
--json output json
--timeout duration set the duration of the client timeout in seconds (default 10s) (default 10s)
```

### SEE ALSO
Expand Down
8 changes: 4 additions & 4 deletions docs/cmd/md/meroxa_endpoints.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ Manage endpoints on Meroxa
### Options inherited from parent commands

```
--config string config file
--debug display any debugging information
--json output json
--timeout duration set the duration of the client timeout in seconds (default 10s) (default 10s)
--cli-config-file string meroxa configuration file
--debug display any debugging information
--json output json
--timeout duration set the duration of the client timeout in seconds (default 10s) (default 10s)
```

### SEE ALSO
Expand Down
8 changes: 4 additions & 4 deletions docs/cmd/md/meroxa_endpoints_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ meroxa endpoints create my-endpoint --protocol http --stream my-stream
### Options inherited from parent commands

```
--config string config file
--debug display any debugging information
--json output json
--timeout duration set the duration of the client timeout in seconds (default 10s) (default 10s)
--cli-config-file string meroxa configuration file
--debug display any debugging information
--json output json
--timeout duration set the duration of the client timeout in seconds (default 10s) (default 10s)
```

### SEE ALSO
Expand Down
8 changes: 4 additions & 4 deletions docs/cmd/md/meroxa_endpoints_describe.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ meroxa endpoints describe [NAME] [flags]
### Options inherited from parent commands

```
--config string config file
--debug display any debugging information
--json output json
--timeout duration set the duration of the client timeout in seconds (default 10s) (default 10s)
--cli-config-file string meroxa configuration file
--debug display any debugging information
--json output json
--timeout duration set the duration of the client timeout in seconds (default 10s) (default 10s)
```

### SEE ALSO
Expand Down
8 changes: 4 additions & 4 deletions docs/cmd/md/meroxa_endpoints_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ meroxa endpoints list [flags]
### Options inherited from parent commands

```
--config string config file
--debug display any debugging information
--json output json
--timeout duration set the duration of the client timeout in seconds (default 10s) (default 10s)
--cli-config-file string meroxa configuration file
--debug display any debugging information
--json output json
--timeout duration set the duration of the client timeout in seconds (default 10s) (default 10s)
```

### SEE ALSO
Expand Down
8 changes: 4 additions & 4 deletions docs/cmd/md/meroxa_endpoints_remove.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ meroxa endpoints remove NAME [flags]
### Options inherited from parent commands

```
--config string config file
--debug display any debugging information
--json output json
--timeout duration set the duration of the client timeout in seconds (default 10s) (default 10s)
--cli-config-file string meroxa configuration file
--debug display any debugging information
--json output json
--timeout duration set the duration of the client timeout in seconds (default 10s) (default 10s)
```

### SEE ALSO
Expand Down
Loading

0 comments on commit e8c3e26

Please sign in to comment.