Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompletePrefix ¶ added in v1.53.0
func CompletePrefix(candidates []string, toComplete string) ([]string, cobra.ShellCompDirective)
CompletePrefix filters candidates by the given prefix for shell completion and disables file completion. This is the single shared helper for ValidArgsFunction and RegisterFlagCompletionFunc implementations; do not reimplement prefix filtering per command.
func FallbackContext ¶ added in v1.15.0
FallbackContext returns a default background context. It is intended to be used in test environments where cmd.Context() returns nil because the command wasn't executed via Execute().
func IsVerbose ¶
IsVerbose checks if the "verbose" flag is set for the given Cobra command. It first checks if the verbose flag is explicitly set on the command. If not, it falls back to the config value.
Parameters:
- cmd: A pointer to a Cobra command from which the "verbose" flag is retrieved.
Returns:
- bool: True if the "verbose" flag is set to true, otherwise false.
func StartChildProcess ¶
StartChildProcess starts a child process with the given exec.Cmd configuration. It sets up the standard input, output, and error streams to be the same as the parent process. Additionally, it captures interrupt signals (ctl + c) and forwards them to the child process.
Parameters:
- c: A pointer to an exec.Cmd struct representing the command to be executed.
Returns:
- error: An error if the command fails to start or exits with a non-zero status. Returns nil if the command completes successfully.
The function starts the command and waits for it to finish.
Types ¶
This section is empty.