MCPcopy
hub / github.com/spf13/cobra / TestStripFlags

Function TestStripFlags

command_test.go:643–714  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

641}
642
643func TestStripFlags(t *testing.T) {
644 tests := []struct {
645 input []string
646 output []string
647 }{
648 {
649 []string{"foo", "bar"},
650 []string{"foo", "bar"},
651 },
652 {
653 []string{"foo", "--str", "-s"},
654 []string{"foo"},
655 },
656 {
657 []string{"-s", "foo", "--str", "bar"},
658 []string{},
659 },
660 {
661 []string{"-i10", "echo"},
662 []string{"echo"},
663 },
664 {
665 []string{"-i=10", "echo"},
666 []string{"echo"},
667 },
668 {
669 []string{"--int=100", "echo"},
670 []string{"echo"},
671 },
672 {
673 []string{"-ib", "echo", "-sfoo", "baz"},
674 []string{"echo", "baz"},
675 },
676 {
677 []string{"-i=baz", "bar", "-i", "foo", "blah"},
678 []string{"bar", "blah"},
679 },
680 {
681 []string{"--int=baz", "-sbar", "-i", "foo", "blah"},
682 []string{"blah"},
683 },
684 {
685 []string{"--bool", "bar", "-i", "foo", "blah"},
686 []string{"bar", "blah"},
687 },
688 {
689 []string{"-b", "bar", "-i", "foo", "blah"},
690 []string{"bar", "blah"},
691 },
692 {
693 []string{"--persist", "bar"},
694 []string{"bar"},
695 },
696 {
697 []string{"-p", "bar"},
698 []string{"bar"},
699 },
700 }

Callers

nothing calls this directly

Calls 3

PersistentFlagsMethod · 0.95
FlagsMethod · 0.95
stripFlagsFunction · 0.85

Tested by

no test coverage detected