Skip to content

Commit 7c9fe92

Browse files
committed
Improve HyphenHyphen flag parse test
1 parent 1b2301f commit 7c9fe92

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

command_test.go

+11
Original file line numberDiff line numberDiff line change
@@ -552,11 +552,22 @@ func TestCommand_RootRaw(t *testing.T) {
552552

553553
func TestCommand_HyphenHyphen(t *testing.T) {
554554
t.Parallel()
555+
var verbose bool
555556
cmd := &serpent.Command{
556557
Handler: (func(i *serpent.Invocation) error {
557558
_, _ = i.Stdout.Write([]byte(strings.Join(i.Args, " ")))
559+
if verbose {
560+
return xerrors.New("verbose should not be true because flag after --")
561+
}
558562
return nil
559563
}),
564+
Options: serpent.OptionSet{
565+
{
566+
Name: "verbose",
567+
Flag: "verbose",
568+
Value: serpent.BoolOf(&verbose),
569+
},
570+
},
560571
}
561572

562573
inv := cmd.Invoke("--", "--verbose", "--friendly")

0 commit comments

Comments
 (0)