mirror of
https://github.com/ipfs/kubo.git
synced 2025-05-21 17:08:13 +08:00
commands/cli: Made Parse return an error if request has unrecognized options
This commit is contained in:

committed by
Juan Batiz-Benet

parent
120ead26f4
commit
db361d9403
@ -37,6 +37,14 @@ func Parse(input []string, root *cmds.Command) (cmds.Request, *cmds.Command, []s
|
||||
return nil, cmd, path, err
|
||||
}
|
||||
|
||||
// check to make sure there aren't any undefined options
|
||||
for k := range opts {
|
||||
if _, found := optDefs[k]; !found {
|
||||
err = fmt.Errorf("Unrecognized option: -%s", k)
|
||||
return nil, cmd, path, err
|
||||
}
|
||||
}
|
||||
|
||||
req := cmds.NewRequest(path, opts, args, cmd, optDefs)
|
||||
|
||||
err = cmd.CheckArguments(req)
|
||||
|
Reference in New Issue
Block a user