mirror of
https://github.com/spf13/cobra
synced 2025-05-07 22:07:23 +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")
|
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
|
## 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
|
||||||
|
|
Loading…
Add table
Reference in a new issue