Fix some issues with cli related to argument values
This commit is contained in:
parent
385657a5c1
commit
928bf64d9d
11
cli/cli.go
11
cli/cli.go
@ -60,7 +60,14 @@ func (this *Cli) Parse (args []string) error {
|
||||
flag.String() +
|
||||
" requires a value")
|
||||
}
|
||||
flag.Value = next()
|
||||
value := next()
|
||||
err := flag.Validate(value)
|
||||
if err != nil {
|
||||
return errors.New(fmt.Sprint (
|
||||
"could not parse ", flag.String(), ": ",
|
||||
err))
|
||||
}
|
||||
flag.Value = value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -207,7 +214,7 @@ func NewFlag (short rune, long string, help string) *Flag {
|
||||
// NewInputFlag creates a new flag that does take in a value. This function will
|
||||
// panic if the given validation function is nil.
|
||||
func NewInputFlag (short rune, long string, help string, defaul string, validate func (string) error) *Flag {
|
||||
if validate != nil {
|
||||
if validate == nil {
|
||||
panic("validate must be non-nil for a flag to take in a value")
|
||||
}
|
||||
return &Flag {
|
||||
|
Loading…
Reference in New Issue
Block a user