diff --git a/commands/cli/parse_test.go b/commands/cli/parse_test.go index fe2c863c303ab9f720ee7981d1b8de2d13cc3708..2c42ddcc4528bf1e0a5168fc3c658efe1e5f66c1 100644 --- a/commands/cli/parse_test.go +++ b/commands/cli/parse_test.go @@ -144,6 +144,12 @@ func TestArgumentParsing(t *testing.T) { commands.StringArg("b", false, true, "another arg"), }, }, + "optionalsecond": { + Arguments: []commands.Argument{ + commands.StringArg("a", true, false, "some arg"), + commands.StringArg("b", false, false, "another arg"), + }, + }, "reversedoptional": { Arguments: []commands.Argument{ commands.StringArg("a", false, false, "some arg"), @@ -213,6 +219,12 @@ func TestArgumentParsing(t *testing.T) { test([]string{"optional", "value!"}, nil, []string{"value!"}) test([]string{"optional"}, nil, []string{}) + test([]string{"optional", "value1", "value2"}, nil, []string{"value1", "value2"}) + + test([]string{"optionalsecond", "value!"}, nil, []string{"value!"}) + test([]string{"optionalsecond", "value1", "value2"}, nil, []string{"value1", "value2"}) + testFail([]string{"optionalsecond"}, "didn't provide any args, 1 required") + testFail([]string{"optionalsecond", "value1", "value2", "value3"}, "provided too many args, takes 2 maximum") test([]string{"reversedoptional", "value1", "value2"}, nil, []string{"value1", "value2"}) test([]string{"reversedoptional", "value!"}, nil, []string{"value!"})