Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,25 @@ func TestParser_WithSubCommand(t *testing.T) {
}
}

func TestParser_WithParentArg(t *testing.T) {
p := NewParser("", "", nil)
f := p.Flag("", "a", nil)
sub := p.AddCommand("test", "", nil)
x := sub.Int("", "a", &Option{Default: "1"})
if e := p.Parse([]string{"--a", "test", "--a", "2"}); e != nil {
t.Error(e.Error())
return
}
if !*f {
t.Error("failed to parse ")
return
}
if *x != 2 {
t.Error("sub command is not parsed, default value should not be bond")
return
}
}

func TestParser_usage(t *testing.T) {
p := NewParser("a", "", &ParserConfig{ContinueOnHelp: true})
test := p.AddCommand("test", "", nil)
Expand Down