You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, if the flag is a SliceValue (e.g. []string), the flag.DefValue is the result of value.String(), which basically is a csv enclaved in "[]", e.g. [foo,bar]. Also, the Set(value string) method of SliceValue will only append the value to existing array. To set the whole flag values to new array, Replace method should be used instead.
To handle slice flags correctly, I suggest make the following changes:
If PersistFlagValues is false, cobra-prompt restore all flags to default value after every command execution.
cobra-prompt.go
However, if the flag is a SliceValue (e.g. []string), the flag.DefValue is the result of
value.String()
, which basically is a csv enclaved in "[]", e.g.[foo,bar]
. Also, theSet(value string)
method of SliceValue will only append thevalue
to existing array. To set the whole flag values to new array,Replace
method should be used instead.To handle slice flags correctly, I suggest make the following changes:
The text was updated successfully, but these errors were encountered: