@cryptotaxi247 / kubo / commits / db361d940

commands/cli: Made Parse return an error if request has unrecognized options

Matt Bell committed Nov 13, 2014 at 02:44 UTC db361d94034daeae882d0bcf3bca615b5dd8bb8f
2 files changed +9 -1
cmd/ipfs2/main.go
+1 -1
@@ -71,7 +71,7 @@ func main() {
71
72 // BEFORE handling the parse error, if we have enough information
73 // AND the user requested help, print it out and exit
74 - if invoc.cmd != nil {
74 + if invoc.req != nil {
75 longH, shortH, err := invoc.requestedHelp()
76 if err != nil {
77 printErr(err)
commands/cli/parse.go
+8
@@ -37,6 +37,14 @@ func Parse(input []string, root *cmds.Command) (cmds.Request, *cmds.Command, []s
37 return nil, cmd, path, err
38 }
39
40 + // check to make sure there aren't any undefined options
41 + for k := range opts {
42 + if _, found := optDefs[k]; !found {
43 + err = fmt.Errorf("Unrecognized option: -%s", k)
44 + return nil, cmd, path, err
45 + }
46 + }
47 +
48 req := cmds.NewRequest(path, opts, args, cmd, optDefs)
49
50 err = cmd.CheckArguments(req)