cobraext

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package cobraext provides extensions and utilities for the Cobra CLI framework.

Package cobraext extends the cobra command-line framework. Provides utilities to enhance cobra's functionality, particularly for handling unknown subcommands when TraverseChildren is enabled. Includes functions for error reporting and command suggestions that work alongside cobra's built-in features.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PipeOrArg

func PipeOrArg(args []string) (string, error)

PipeOrArg checks if there are any arguments passed to the command.

func SetFlagIfNotSet added in v0.0.13

func SetFlagIfNotSet(flag *pflag.Flag, value string) error

SetFlagIfNotSet sets a flag's value only if it has not been set yet.

func UnknownSubcommandAction

func UnknownSubcommandAction(cmd *cobra.Command, args []string) error

UnknownSubcommandAction handles unknown cobra subcommands. Implements cobra.Command.RunE to provide helpful error messages and suggestions when an unknown subcommand is used. Required when TraverseChildren is true, as this disables cobra's built-in suggestion system. See: - https://github.com/spf13/cobra/issues/981 - https://github.com/containerd/nerdctl/blob/242e6fc6e861b61b878bd7df8bf25e95674c036d/cmd/nerdctl/main.go#L401-L418

Types

This section is empty.

Jump to

Keyboard shortcuts

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