testutil

package
v0.11.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateCommandExamples

func ValidateCommandExamples(rootCmd *cobra.Command, example string) error

ValidateCommandExamples combines parsing and validation

func ValidateExampleCommand

func ValidateExampleCommand(rootCmd *cobra.Command, exampleCmd ExampleCommand) error

ValidateExampleCommand verifies command exists and flags are valid - Uses Cobra's Find() to locate command in tree - Checks both command-specific and persistent flags

Types

type ExampleCommand

type ExampleCommand struct {
	Raw         string            // Original command line
	Binary      string            // Binary name (should be "kdn")
	Args        []string          // Subcommands and positional arguments
	FlagPresent map[string]bool   // Flags that were present in the command
	FlagValues  map[string]string // Values for flags (empty string if no value provided)
	Flags       map[string]string // Deprecated: use FlagPresent and FlagValues instead
	EnvVars     map[string]string // Environment variable assignments that preceded the command
}

ExampleCommand represents a parsed command from an Example string

func ParseExampleCommands

func ParseExampleCommands(example string) ([]ExampleCommand, error)

ParseExampleCommands extracts kdn commands from Example string - Ignores empty lines and comment lines (starting with #) - Lines may be prefixed with VAR=VALUE environment variable assignments - Returns error if non-comment lines do not contain a kdn command

Jump to

Keyboard shortcuts

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