Help us shape the future of Go! Take the 2026 Go Developer Survey

cmdutil

package
v1.61.1 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2026 License: MIT Imports: 9 Imported by: 0

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

func FallbackContext() context.Context

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

func IsVerbose(cmd *cobra.Command) bool

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

func StartChildProcess(c *exec.Cmd) error

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.

Jump to

Keyboard shortcuts

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