Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Improve flag value resets between command executions #3

Merged
merged 2 commits into from
Nov 24, 2023

Conversation

avirtopeanu-ionos
Copy link
Collaborator

@avirtopeanu-ionos avirtopeanu-ionos commented Nov 24, 2023

Currently, for flags that contain slices as values, the defaul CustomFlagResetBehaviour func would actually call Set which would append flag.DefValue to its previous value, rather than resetting to this default on command executions.

I found this nifty little interface SliceValue to which we can cast our pflag.Value. SliceValue exposes Reset() which we can use instead of Set() if the cast is successful.

@avirtopeanu-ionos avirtopeanu-ionos merged commit 23ae6fb into main Nov 24, 2023
@avirtopeanu-ionos avirtopeanu-ionos deleted the fix/reset-slice-flags branch November 24, 2023 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant