API: Export ActionCommands() and ActionFlags() for cobra command#888
API: Export ActionCommands() and ActionFlags() for cobra command#888maxlandon wants to merge 2 commits intocarapace-sh:masterfrom
Conversation
|
This is something I also had on my mind for quite a while but haven't done so far. What I am thinking of now though, and what would oppose doing this, is that Might still be useful though anyway, so I'll give it some more thought. |
|
Thanks for these explanations. |
|
Pinging on this to know if there is a reason why the ActionFlags has not been exposed ? Asking this because the initial intent was to give some way to dynamically complete commands/flags, should consumer libraries need it. |
|
Changes
This PR simply exports the ActionCommands() and ActionFlags() which both receive
a cobra command as argument.
Reasons
The reason is simple: more and more people will try and succeed (some already do)
in binding/executing cobra commands dynamically, for that very reason might want
to beneficiate from the usual completion utilities, like caching completions.
An example would be a tool of which a significant part of its command tree might
available/unavailable based on different conditions, and rather than having to
always query those on the wire, might just use cached command completions.
Included commits