Skip to content
Myr

Add example for making persistent flags required (#1135)

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

authored by Adam Demuri · committed by GitHub · parent 723d0c3 · Browse files · 1 file+6 added−0 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+6 added−0 removed

  • other:+6 added−0 removed

1 file+6 added−0 removed

modified:README.md+6 added
417 unmodified lines
418rootCmd.Flags().StringVarP(&Region, "region", "r", "", "AWS region (required)")419rootCmd.MarkFlagRequired("region")420```421422Or, for persistent flags:423```go424rootCmd.PersistentFlags().StringVarP(&Region, "region", "r", "", "AWS region (required)")425rootCmd.MarkPersistentFlagRequired("region")426```427428## Positional and Custom Arguments429430Validation of positional arguments can be specified using the `Args` field431of `Command`.
335 unmodified lines