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

Support IsSet() method on flags #453

Closed
nikhiljindal opened this issue May 23, 2017 · 4 comments
Closed

Support IsSet() method on flags #453

nikhiljindal opened this issue May 23, 2017 · 4 comments

Comments

@nikhiljindal
Copy link

To distinguish when the flag got default value because user didnt set any or user explicitly set the flag to same value as the default value.

@n10v
Copy link
Collaborator

n10v commented May 23, 2017

You can use Changed func to check it:

if cmd.Flags().Changed("someFlag") {
    // user set the flag
}

@nikhiljindal
Copy link
Author

Thanks! That worked.

@xieyuschen
Copy link

xieyuschen commented Jul 28, 2022

Shall we also provide a function like:

func (f *FlagSet) GetChangedList() []string 

So we could register a handler map to process the corresponding flags.

@johntdyer
Copy link

@xieyuschen that would be nice

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

No branches or pull requests

4 participants