|
|
|
@ -59,9 +59,9 @@ func TestCommandFlagParsing(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
func TestParseAndRunShortOpts(t *testing.T) {
|
|
|
|
|
cases := []struct {
|
|
|
|
|
testArgs []string
|
|
|
|
|
expectedErr error
|
|
|
|
|
expectedArgs []string
|
|
|
|
|
testArgs []string
|
|
|
|
|
expectedErr error
|
|
|
|
|
expectedArgs []string
|
|
|
|
|
}{
|
|
|
|
|
{[]string{"foo", "test", "-a"}, nil, []string{}},
|
|
|
|
|
{[]string{"foo", "test", "-c", "arg1", "arg2"}, nil, []string{"arg1", "arg2"}},
|
|
|
|
@ -71,18 +71,18 @@ func TestParseAndRunShortOpts(t *testing.T) {
|
|
|
|
|
{[]string{"foo", "test", "-cf"}, nil, []string{}},
|
|
|
|
|
{[]string{"foo", "test", "-acf"}, nil, []string{}},
|
|
|
|
|
{[]string{"foo", "test", "-invalid"}, errors.New("flag provided but not defined: -invalid"), []string{}},
|
|
|
|
|
{[]string{"foo", "test", "-acf", "arg1", "-invalid"}, nil, []string{"arg1" ,"-invalid"}},
|
|
|
|
|
{[]string{"foo", "test", "-acf", "arg1", "-invalid"}, nil, []string{"arg1", "-invalid"}},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var args []string
|
|
|
|
|
cmd := Command{
|
|
|
|
|
Name: "test",
|
|
|
|
|
Usage: "this is for testing",
|
|
|
|
|
Description: "testing",
|
|
|
|
|
Action: func(c *Context) error {
|
|
|
|
|
args = c.Args()
|
|
|
|
|
return nil
|
|
|
|
|
},
|
|
|
|
|
Name: "test",
|
|
|
|
|
Usage: "this is for testing",
|
|
|
|
|
Description: "testing",
|
|
|
|
|
Action: func(c *Context) error {
|
|
|
|
|
args = c.Args()
|
|
|
|
|
return nil
|
|
|
|
|
},
|
|
|
|
|
SkipArgReorder: true,
|
|
|
|
|
UseShortOptionHandling: true,
|
|
|
|
|
Flags: []Flag{
|
|
|
|
|