diff --git a/cmd/ipfs2/main.go b/cmd/ipfs2/main.go index 782491e56..454eb48b9 100644 --- a/cmd/ipfs2/main.go +++ b/cmd/ipfs2/main.go @@ -71,7 +71,7 @@ func main() { // BEFORE handling the parse error, if we have enough information // AND the user requested help, print it out and exit - if invoc.cmd != nil { + if invoc.req != nil { longH, shortH, err := invoc.requestedHelp() if err != nil { printErr(err) diff --git a/commands/cli/parse.go b/commands/cli/parse.go index b84ecca76..2940f7268 100644 --- a/commands/cli/parse.go +++ b/commands/cli/parse.go @@ -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)