Add example for making persistent flags required (#1135)

This commit is contained in:
Adam Demuri 2020-10-14 09:53:09 -06:00 committed by GitHub
parent 723d0c36fc
commit 142dfb15a8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -419,6 +419,12 @@ rootCmd.Flags().StringVarP(&Region, "region", "r", "", "AWS region (required)")
rootCmd.MarkFlagRequired("region") rootCmd.MarkFlagRequired("region")
``` ```
Or, for persistent flags:
```go
rootCmd.PersistentFlags().StringVarP(&Region, "region", "r", "", "AWS region (required)")
rootCmd.MarkPersistentFlagRequired("region")
```
## Positional and Custom Arguments ## Positional and Custom Arguments
Validation of positional arguments can be specified using the `Args` field Validation of positional arguments can be specified using the `Args` field