carapace icon indicating copy to clipboard operation
carapace copied to clipboard

API: Export ActionCommands() and ActionFlags() for cobra command

Open maxlandon opened this issue 10 months ago • 4 comments

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

  • Add a CacheF function force the engine to refresh within timeout if needed.
  • Export cobra subcommand/flag completion.

maxlandon avatar Aug 08 '23 01:08 maxlandon