Skip to content
Myr

Improve MarkFlagsMutuallyExclusive example in User Guide (#1904)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by janhn · committed by GitHub · parent d022c0f · Browse files · 1 file+2 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+2 added−2 removed

  • other:+2 added−2 removed

1 file+2 added−2 removed

modified:user_guide.md+2 added-2 removed
311 unmodified lines
312313You can also prevent different flags from being provided together if they represent mutually314exclusive options such as specifying an output format as either `--json` or `--yaml` but never both:315```go316rootCmd.Flags().BoolVar(&u, "json", false, "Output in JSON")317rootCmd.Flags().BoolVar(&pw, "yaml", false, "Output in YAML")316rootCmd.Flags().BoolVar(&ofJson, "json", false, "Output in JSON")317rootCmd.Flags().BoolVar(&ofYaml, "yaml", false, "Output in YAML")318rootCmd.MarkFlagsMutuallyExclusive("json", "yaml")319```320321In both of these cases:
374 unmodified lines