From 30e968754e31fe2ce9532886dc1b8b7dcf140230 Mon Sep 17 00:00:00 2001 From: Matt Bell Date: Fri, 31 Oct 2014 14:10:04 -0700 Subject: [PATCH] commands/cli: Error if no subcommand matched --- commands/cli/parse.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/commands/cli/parse.go b/commands/cli/parse.go index 2a6aa7f95..39fceef8f 100644 --- a/commands/cli/parse.go +++ b/commands/cli/parse.go @@ -1,6 +1,7 @@ package cli import ( + "errors" "fmt" "strings" @@ -30,6 +31,10 @@ func Parse(input []string, roots ...*cmds.Command) (cmds.Request, *cmds.Command, } } + if maxLength == 0 { + return nil, nil, errors.New("Not a valid subcommand") + } + // TODO: figure out how to know when to read given file(s) as an input stream // (instead of filename arg string)