Updating server dependancies. (#7246)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
2c895ee66e
Коммит
96eab12027
30
vendor/github.com/spf13/cobra/README.md
сгенерированный
поставляемый
30
vendor/github.com/spf13/cobra/README.md
сгенерированный
поставляемый
@@ -485,6 +485,36 @@ when the `--author` flag is not provided by user.
|
||||
|
||||
More in [viper documentation](https://github.com/spf13/viper#working-with-flags).
|
||||
|
||||
## Positional and Custom Arguments
|
||||
|
||||
Validation of positional arguments can be specified using the `Args` field.
|
||||
|
||||
The follow validators are built in:
|
||||
|
||||
- `NoArgs` - the command will report an error if there are any positional args.
|
||||
- `ArbitraryArgs` - the command will accept any args.
|
||||
- `OnlyValidArgs` - the command will report an error if there are any positional args that are not in the ValidArgs list.
|
||||
- `MinimumNArgs(int)` - the command will report an error if there are not at least N positional args.
|
||||
- `MaximumNArgs(int)` - the command will report an error if there are more than N positional args.
|
||||
- `ExactArgs(int)` - the command will report an error if there are not exactly N positional args.
|
||||
- `RangeArgs(min, max)` - the command will report an error if the number of args is not between the minimum and maximum number of expected args.
|
||||
|
||||
A custom validator can be provided like this:
|
||||
|
||||
```go
|
||||
|
||||
Args: func validColorArgs(cmd *cobra.Command, args []string) error {
|
||||
if err := cli.RequiresMinArgs(1)(cmd, args); err != nil {
|
||||
return err
|
||||
}
|
||||
if myapp.IsValidColor(args[0]) {
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("Invalid color specified: %s", args[0])
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
In the example below, we have defined three commands. Two are at the top level
|
||||
|
||||
Ссылка в новой задаче
Block a user