Skip to content

Commit

Permalink
Enable option with empty argument (#5)
Browse files Browse the repository at this point in the history
Signed-off-by: plar <[email protected]>
  • Loading branch information
plar authored Feb 28, 2024
1 parent 38b6544 commit 67a841c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
5 changes: 5 additions & 0 deletions command/arg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ func (m *MockArg) Apply(cli safecli.CommandAppender) error {
func TestArguments(t *testing.T) { check.TestingT(t) }

var _ = check.Suite(&test.ArgumentSuite{Cmd: "cmd", Arguments: []test.ArgumentTest{
{
Name: "NewArguments with NoopArgument",
Argument: command.NewNoopArgument(),
ExpectedCLI: []string{"cmd"},
},
{
Name: "NewErrorArgument without error",
Argument: command.NewErrorArgument(nil),
Expand Down
2 changes: 0 additions & 2 deletions command/option_arg.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ func (o optionArg) Apply(cmd safecli.CommandAppender) error {
func newOptionArg(name, arg string, isArgRedacted bool) Applier {
if err := validateOptionName(name); err != nil {
return err
} else if arg == "" {
return noopArgument{}
}
return optionArg{
name: name,
Expand Down
5 changes: 3 additions & 2 deletions command/option_arg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ var _ = check.Suite(&test.ArgumentSuite{Cmd: "cmd", Arguments: []test.ArgumentTe
{
Name: "NewOptionWithArgument with empty argument",
Argument: command.NewOptionWithArgument("--option", ""),
ExpectedCLI: []string{"cmd"},
ExpectedCLI: []string{"cmd", "--option="},
},

{
Expand All @@ -65,6 +65,7 @@ var _ = check.Suite(&test.ArgumentSuite{Cmd: "cmd", Arguments: []test.ArgumentTe
{
Name: "NewOptionWithRedactedArgument with empty argument",
Argument: command.NewOptionWithRedactedArgument("--option", ""),
ExpectedCLI: []string{"cmd"},
ExpectedCLI: []string{"cmd", "--option="},
ExpectedLog: "cmd --option=<****>",
},
}})

0 comments on commit 67a841c

Please sign in to comment.