Documentation
¶
Index ¶
- func ResetArgs(t *testing.T, cmd *cobra.Command)
- type MockFlagsWithComma
- func (m *MockFlagsWithComma) Append(value string) error
- func (m *MockFlagsWithComma) GetSlice() []string
- func (m *MockFlagsWithComma) Replace(value []string) error
- func (m *MockFlagsWithComma) Set(value string) error
- func (m *MockFlagsWithComma) String() string
- func (m *MockFlagsWithComma) Type() string
- type MockFlagsWithSemicolon
- func (m *MockFlagsWithSemicolon) Append(value string) error
- func (m *MockFlagsWithSemicolon) GetSlice() []string
- func (m *MockFlagsWithSemicolon) Replace(value []string) error
- func (m *MockFlagsWithSemicolon) Set(value string) error
- func (m *MockFlagsWithSemicolon) String() string
- func (m *MockFlagsWithSemicolon) Type() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ResetArgs ¶
ResetArgs resets arguments for the command. It is desired to be a helpful function for the cmd.SetArgs in the case of calling multiple times in a unit test, as cmd.SetArgs doesn't reset the flag value as expected.
**Warning**: this is only compatible with following flag types:
- the implementations of pflag.Value
- the built-in implementations of pflag.SliceValue
- the custom implementations of pflag.SliceValue that are split by comma ","
see https://github.com/spf13/cobra/issues/2079#issuecomment-1870115781 for more detail info
Types ¶
type MockFlagsWithComma ¶
type MockFlagsWithComma struct { Ary []string // contains filtered or unexported fields }
func (*MockFlagsWithComma) Append ¶
func (m *MockFlagsWithComma) Append(value string) error
func (*MockFlagsWithComma) GetSlice ¶
func (m *MockFlagsWithComma) GetSlice() []string
func (*MockFlagsWithComma) Replace ¶
func (m *MockFlagsWithComma) Replace(value []string) error
func (*MockFlagsWithComma) Set ¶
func (m *MockFlagsWithComma) Set(value string) error
func (*MockFlagsWithComma) String ¶
func (m *MockFlagsWithComma) String() string
func (*MockFlagsWithComma) Type ¶
func (m *MockFlagsWithComma) Type() string
type MockFlagsWithSemicolon ¶
type MockFlagsWithSemicolon struct { Ary []string // contains filtered or unexported fields }
func (*MockFlagsWithSemicolon) Append ¶
func (m *MockFlagsWithSemicolon) Append(value string) error
func (*MockFlagsWithSemicolon) GetSlice ¶
func (m *MockFlagsWithSemicolon) GetSlice() []string
func (*MockFlagsWithSemicolon) Replace ¶
func (m *MockFlagsWithSemicolon) Replace(value []string) error
func (*MockFlagsWithSemicolon) Set ¶
func (m *MockFlagsWithSemicolon) Set(value string) error
func (*MockFlagsWithSemicolon) String ¶
func (m *MockFlagsWithSemicolon) String() string
func (*MockFlagsWithSemicolon) Type ¶
func (m *MockFlagsWithSemicolon) Type() string
Click to show internal directories.
Click to hide internal directories.