prevent removal of valid arguments

This commit is contained in:
deads2k
2015-04-24 11:39:11 -04:00
parent 3c187e9045
commit 36aee64abe
2 changed files with 38 additions and 9 deletions

View File

@ -483,6 +483,32 @@ func TestInvalidSubCommandFlags(t *testing.T) {
}
func TestSubCommandArgEvaluation(t *testing.T) {
cmd := initializeWithRootCmd()
first := &Command{
Use: "first",
Run: func(cmd *Command, args []string) {
},
}
cmd.AddCommand(first)
second := &Command{
Use: "second",
Run: func(cmd *Command, args []string) {
fmt.Fprintf(cmd.Out(), "%v", args)
},
}
first.AddCommand(second)
result := simpleTester(cmd, "first second first third")
expectedOutput := fmt.Sprintf("%v", []string{"first third"})
if result.Output != expectedOutput {
t.Errorf("exptected %v, got %v", expectedOutput, result.Output)
}
}
func TestPersistentFlags(t *testing.T) {
fullSetupTest("echo -s something -p more here")