-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
is there a way to add flags dynamically? #1758
Comments
Hi @skeetwu. You can handle flags dynamically by setting to I hope this helps. |
Hi @marckhouzam , thx for your response. |
Looks like you disable flag parsing, then once the command gets called, you read the list of flags from an API, you create those flags and then ask Cobra to parse them. This seems good to me. |
ok, great thx for your comments. |
we build a binary with Cobra, the primary function is to collect input and send all arguments to a restful server, this server will call other functions to create a K8S cluster.
when we do it, there are a lot of arguments, and we need to enhance and change them more regularly, so, if there is a way to add flags dynamically, it will be beneficial for us.
I have written some code to implement this feature, but I am not familiar with Go lang and Corba, I'm not sure we are on the right way, if there is a more good way, please help me figure it out.
API parts, which return dynamic data.
parse API result to flag
commands parts
CLI result
The text was updated successfully, but these errors were encountered: