Skip to content

Commit

Permalink
Add example for making persistent flags required (spf13#1135)
Browse files Browse the repository at this point in the history
  • Loading branch information
ademuri committed Oct 14, 2020
1 parent 723d0c3 commit 142dfb1
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Expand Up @@ -419,6 +419,12 @@ rootCmd.Flags().StringVarP(&Region, "region", "r", "", "AWS region (required)")
rootCmd.MarkFlagRequired("region")
```

Or, for persistent flags:
```go
rootCmd.PersistentFlags().StringVarP(&Region, "region", "r", "", "AWS region (required)")
rootCmd.MarkPersistentFlagRequired("region")
```

## Positional and Custom Arguments

Validation of positional arguments can be specified using the `Args` field
Expand Down

0 comments on commit 142dfb1

Please sign in to comment.