fix: allow overridding default string array (#6873)

* fix: allow overridding default string array

* Cleanup code

* fixup! Cleanup code

* fixup! Cleanup code

* fixup! Cleanup code

* fixup! Cleanup code
This commit is contained in:
Ammar Bandukwala
2023-03-29 20:09:20 -05:00
committed by GitHub
parent 1c7adc0ebd
commit 58d650c2bb
6 changed files with 91 additions and 107 deletions

View File

@ -247,6 +247,7 @@ func TestCommand_FlagOverride(t *testing.T) {
Use: "1",
Options: clibase.OptionSet{
{
Name: "flag",
Flag: "f",
Value: clibase.DiscardValue,
},
@ -256,6 +257,7 @@ func TestCommand_FlagOverride(t *testing.T) {
Use: "2",
Options: clibase.OptionSet{
{
Name: "flag",
Flag: "f",
Value: clibase.StringOf(&flag),
},
@ -527,11 +529,17 @@ func TestCommand_EmptySlice(t *testing.T) {
}
}
// Base-case
// Base-case, uses default.
err := cmd("bad", "bad", "bad").Invoke().Run()
require.NoError(t, err)
// Reset to nothing at all.
inv := cmd().Invoke("--arr", "")
err = inv.Run()
require.NoError(t, err)
// Override
inv = cmd("great").Invoke("--arr", "great")
err = inv.Run()
require.NoError(t, err)
}