command

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 7, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

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

View Source
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

func ActiveFilters(cmd *cobra.Command, consoleFilters []string) []string

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

func HideCarapace(root *cobra.Command)

HideCarapace recursively hides carapace's internal _carapace completion command so it is never offered as a normal user command.

func HideFiltered

func HideFiltered(root *cobra.Command, consoleFilters []string)

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

func ResetCompletionFlagState(root *cobra.Command, args []string)

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

func ResetFlagsDefaults(target *cobra.Command)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL