mirror of
https://github.com/spf13/cobra
synced 2025-05-06 05:17:21 +00:00
add persistent flag in the MarkRequired exemple as their is diffrences between Local and Persistent flags.
This commit is contained in:
parent
f2b07da1e2
commit
6d52be5440
1 changed files with 2 additions and 0 deletions
|
@ -379,6 +379,8 @@ when a flag has not been set, mark it as required:
|
|||
```go
|
||||
rootCmd.Flags().StringVarP(&Region, "region", "r", "", "AWS region (required)")
|
||||
rootCmd.MarkFlagRequired("region")
|
||||
rootCmd.PersistentFlags().StringVarP(&Database, "database", "d", "Database IP")
|
||||
rootCmd.MarkPersistentFlagRequired("database")
|
||||
```
|
||||
|
||||
## Positional and Custom Arguments
|
||||
|
|
Loading…
Add table
Reference in a new issue