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

Add RemoveFlag() function #358

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

tiegz
Copy link

@tiegz tiegz commented Sep 15, 2022

This adds the ability to remove a Flag from a FlagSet, e.g. flagSet.RemoveFlag("my-flag")

My end-goal is to allow cobra commands to opt-out of PersistentFlags() that they inherit. Please LMK if I'm on the wrong track here.

(plus a few formatting changes)

This was raising this error, which was added in go 1.10:
./flag_test.go:1242:3: fmt.Println arg list ends with redundant newline
@CLAassistant
Copy link

CLAassistant commented Sep 15, 2022

CLA assistant check
All committers have signed the CLA.

if len(flagSet.formal) != 1 {
t.Errorf("Unexpected result adding a Flag to a FlagSet %v", flagSet)
}
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Backfilling this test for AddFlag().

@tiegz
Copy link
Author

tiegz commented Mar 10, 2023

ping

hoshsadiq pushed a commit to zulucmd/zflag that referenced this pull request Apr 23, 2023
This adds the ability to remove a Flag from a FlagSet, e.g. `flagSet.RemoveFlag("my-flag")`

My end-goal is to allow cobra commands to opt-out of PersistentFlags() that they inherit. Please LMK if I'm on the wrong track here.

(plus a few formatting changes)

Merge spf13#358
@tiegz
Copy link
Author

tiegz commented Nov 14, 2023

ping

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.

None yet

2 participants