mirror of
https://github.com/spf13/cobra
synced 2025-05-07 05:47:26 +00:00
Add MarkPersistentFlagRequired to README
This commit is contained in:
parent
89c7ffb512
commit
a419fb9dfa
1 changed files with 6 additions and 0 deletions
|
@ -404,6 +404,12 @@ rootCmd.Flags().StringVarP(&Region, "region", "r", "", "AWS region (required)")
|
|||
rootCmd.MarkFlagRequired("region")
|
||||
```
|
||||
|
||||
Pesistent flags should be marked as required using a separate function:
|
||||
```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
|
||||
|
|
Loading…
Add table
Reference in a new issue