added a flag to disable flags
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
package cobra
|
||||
|
||||
import (
|
||||
"os"
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
@ -112,3 +113,23 @@ func TestStripFlags(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func Test_DisableFlagParsing(t *testing.T) {
|
||||
as := []string{"-v", "-race", "-file", "foo.go"}
|
||||
targs := []string{}
|
||||
cmdPrint := &Command{
|
||||
DisableFlagParsing: true,
|
||||
Run: func(cmd *Command, args []string) {
|
||||
targs = args
|
||||
},
|
||||
}
|
||||
osargs := []string{"cmd"}
|
||||
os.Args = append(osargs, as...)
|
||||
err := cmdPrint.Execute()
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if !reflect.DeepEqual(as, targs) {
|
||||
t.Errorf("expected: %v, got: %v", as, targs)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user