mirror of
https://github.com/spf13/cobra
synced 2024-11-24 14:47:12 +00:00
Improve MarkFlagsMutuallyExclusive example in User Guide (#1904)
This commit is contained in:
parent
d022c0fe2b
commit
8b8ee8754c
1 changed files with 2 additions and 2 deletions
|
@ -313,8 +313,8 @@ rootCmd.MarkFlagsRequiredTogether("username", "password")
|
||||||
You can also prevent different flags from being provided together if they represent mutually
|
You can also prevent different flags from being provided together if they represent mutually
|
||||||
exclusive options such as specifying an output format as either `--json` or `--yaml` but never both:
|
exclusive options such as specifying an output format as either `--json` or `--yaml` but never both:
|
||||||
```go
|
```go
|
||||||
rootCmd.Flags().BoolVar(&u, "json", false, "Output in JSON")
|
rootCmd.Flags().BoolVar(&ofJson, "json", false, "Output in JSON")
|
||||||
rootCmd.Flags().BoolVar(&pw, "yaml", false, "Output in YAML")
|
rootCmd.Flags().BoolVar(&ofYaml, "yaml", false, "Output in YAML")
|
||||||
rootCmd.MarkFlagsMutuallyExclusive("json", "yaml")
|
rootCmd.MarkFlagsMutuallyExclusive("json", "yaml")
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue