Skip to content

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 tiegz force-pushed the tiegz/allow-removing-flags branch from daa8925 to 87758c1 Compare September 16, 2022 00:01
@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.

2 participants