cmd

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2026 License: MIT Imports: 4 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 Output

func Output(cmd *exec.Cmd) ([]byte, error)

Output executes a command and returns stdout, with stderr in error if it fails

func Run

func Run(cmd *exec.Cmd) error

Run executes a command and returns stderr in the error message if it fails

Types

This section is empty.

Jump to

Keyboard shortcuts

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