cmd

package
v0.19.2 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package cmd provides helpers for executing shell commands with proper error handling.

This package wraps os/exec.Cmd to capture stderr and include it in error messages, making command failures more informative for users.

Usage

cmd := exec.Command("git", "status")
if err := cmd.Run(cmd); err != nil {
    // err contains stderr output if available
    return fmt.Errorf("git failed: %w", err)
}

// For commands that return output:
output, err := cmd.Output(exec.Command("git", "branch"))
if err != nil {
    // err contains stderr output
}

Design Notes

The wt tool shells out to git/gh/glab CLIs rather than using Go libraries. This approach is simpler, more reliable, and ensures compatibility with user configurations (SSH keys, credential helpers, etc.).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OutputContext added in v0.8.0

func OutputContext(ctx context.Context, dir, name string, args ...string) ([]byte, error)

OutputContext executes a command with context support and verbose logging, returning stdout.

func RunContext added in v0.8.0

func RunContext(ctx context.Context, dir, name string, args ...string) error

RunContext executes a command with context support and verbose logging.

Types

This section is empty.

Jump to

Keyboard shortcuts

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