-
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
Things we want in v2 #440
Comments
What other API mistakes have we made? |
I want to merge #284 as fast as we can. BTW it fixes 2nd point. |
I can't understand 3rd point. Can you please explain what do you mean there? |
Say I call |
#284 fixes that too. |
Hmm, I would like a autocomplete generation build in the cobra program itself. Could look into that. Should be easy and finished pretty fast. |
I would love to be able to define flags when I'm instantiating a |
@pbdeuchler Can you please write a code example of your wish, of course if it's possible. |
For sure! Here's some off the cuff psuedo code... I'd be open to still requiring function calls to define the flags (if there's background logic or if the pflags library requires it) as long as I can create them somehow during my command declaration
Where cmd.FlagDeclaration is a slice of interfaces or something, open to suggestions or critiques |
@pbdeuchler What's the problem to use |
No worries, happy to help... To be clear, this is about defining flags, not fetching them. Currently, since flag declarations are essentially methods on an already instantiated command struct I'm forced to call them outside of the command declaration... this plus the fact that often the only closure in my cli project I have complete control over is the
Several problems here:
If I were able to define flags as part of defining commands I'd be able to end up with much nicer code that's all pleasantly separated by concerns |
You don't have to use it: internal.RootCmd.PersistentFlags().StringP("host", "h", "localhost", "the host to query")
What's the problem to define it in the same package?
You can create multiple files (like Sorry for my dumb questions, but I can't actually fully understand the problem. The code example you provided is the normal practice and you should do this way. |
You want a declarative definition of flags in the command declaration. Not the imperative definition required today. I like it. Probably something that could be done without a -v2... |
I notice that your 'declarative' is not really declarative. Would it make and sense to have it be truely declarative? Some sort of thing like:
And then a cobra command could take a |
I would like to start working on 2.0.0 version this week and opened a new milestone for it. If you have some feature requests/bug reports/any other enhancements for 2.0.0, please open the separate issue with detailed description. /cc @eparis |
Talking about labeling something 1.0 (to solve #259) and I hope this issue can be a place for us to put API breaking changes we'd like to see in v2.
The text was updated successfully, but these errors were encountered: