Documentation
¶
Overview ¶
Package command provides pure utilities for manipulating cobra command trees: matching commands against console filters, hiding filtered or internal commands, resetting reused flag state, and locating the command targeted by a line of input. None of these functions depend on console state, so they can be tested in isolation; the root console package wraps them in its own methods.
Index ¶
Constants ¶
const FilterKey = "console-hidden"
FilterKey is the cobra annotation key whose comma-separated value marks a command with the filters that hide it. The console re-exports this as CommandFilterKey for application use.
Variables ¶
This section is empty.
Functions ¶
func ActiveFilters ¶
ActiveFilters returns the console filters that cmd (or its nearest annotated ancestor) declares itself incompatible with. A non-empty result means the command is currently hidden/unavailable under the given console filters.
func HideCarapace ¶
HideCarapace recursively hides carapace's internal _carapace completion command so it is never offered as a normal user command.
func HideFiltered ¶
HideFiltered hides every subcommand of root that matches an active console filter, so it is not shown in help strings or offered as a completion. Commands already hidden are left untouched.
func ResetCompletionFlagState ¶
ResetCompletionFlagState clears flag state left over from a previous completion or execution on a reused command tree, before carapace parses the current input. It restores the target command's flag defaults (shared with the execution path) and resets ArgsLenAtDash along the command's lineage.
func ResetFlagsDefaults ¶
ResetFlagsDefaults resets every flag on target back to its registered default value and clears its Changed state. Console reuses cobra command trees across completions and executions; when the application supplies a command tree directly (no generator), flag state parsed by an earlier run would otherwise leak into later ones.
Types ¶
This section is empty.