commandrunner

package
v1.12.4 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package commandrunner provides helpers for executing Cobra commands while capturing their output and translating k3d logging semantics.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MergeCommandError

func MergeCommandError(base error, res CommandResult) error

MergeCommandError enriches a base error with captured stdout/stderr when available.

Types

type CobraCommandRunner

type CobraCommandRunner struct{}

CobraCommandRunner executes Cobra commands while mirroring k3d logging semantics.

func NewCobraCommandRunner

func NewCobraCommandRunner() *CobraCommandRunner

NewCobraCommandRunner creates a command runner that wraps Cobra execution with stdout/stderr capture compatible with k3d's logging behavior.

func (*CobraCommandRunner) Run

func (r *CobraCommandRunner) Run(
	ctx context.Context,
	cmd *cobra.Command,
	args []string,
) (CommandResult, error)

Run executes the provided Cobra command while capturing stdout/stderr.

type CommandResult

type CommandResult struct {
	Stdout string
	Stderr string
}

CommandResult captures the stdout and stderr collected during a Cobra command execution.

type CommandRunner

type CommandRunner interface {
	Run(ctx context.Context, cmd *cobra.Command, args []string) (CommandResult, error)
}

CommandRunner executes Cobra commands while capturing their output.

Jump to

Keyboard shortcuts

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