Skip to content

Commit

Permalink
Improve MarkFlagsMutuallyExclusive example in User Guide (#1904)
Browse files Browse the repository at this point in the history
  • Loading branch information
janhn authored Feb 6, 2023
1 parent d022c0f commit 8b8ee87
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions user_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,8 @@ rootCmd.MarkFlagsRequiredTogether("username", "password")
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:
```go
rootCmd.Flags().BoolVar(&u, "json", false, "Output in JSON")
rootCmd.Flags().BoolVar(&pw, "yaml", false, "Output in YAML")
rootCmd.Flags().BoolVar(&ofJson, "json", false, "Output in JSON")
rootCmd.Flags().BoolVar(&ofYaml, "yaml", false, "Output in YAML")
rootCmd.MarkFlagsMutuallyExclusive("json", "yaml")
```

Expand Down

0 comments on commit 8b8ee87

Please sign in to comment.