cmd

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package cmd implements the stacked command-line dispatcher and all of its subcommands. Subcommands self-register via init() functions calling register.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Execute

func Execute() (rc int)

Execute parses os.Args, dispatches to the matching subcommand, and returns the process exit code. With no arguments, or help/-h/--help, it prints help and returns 0. version/-v/--version prints the version and returns 0. An unknown command prints an error to stderr and returns 1. A command that returns an error prints "st: <err>" to stderr and returns 1. A panic in any command is recovered into a structured error and exitInternal so the process never crashes with a raw stack trace and the runtime's exit code 2. help and version accept --json and emit the same information as a machine-readable payload.

Types

type Command

type Command struct {
	// Name is the primary invocation name of the command.
	Name string
	// Aliases are alternate names that also invoke the command.
	Aliases []string
	// Summary is a one-line description shown in help output.
	Summary string
	// Usage is a short usage string, e.g. "st create <name> [-m <msg>] [-a]".
	Usage string
	// Run executes the command with the arguments following the command name.
	Run func(args []string) error
	// NewFlagSet, when set, builds a fresh flag set declaring every flag the
	// command accepts, for help introspection. Run builds its set from the same
	// per-command constructor (cmd/flagsets.go), so a command's flags are declared
	// once and `help --json` cannot drift from what Run parses. Commands whose
	// only flag is --json leave it nil.
	NewFlagSet func() *flag.FlagSet
}

Command describes a single stacked subcommand.

Directories

Path Synopsis
Command st is stacked: a minimal, dependency-free, login-free CLI for managing stacked diffs on top of git.
Command st is stacked: a minimal, dependency-free, login-free CLI for managing stacked diffs on top of git.

Jump to

Keyboard shortcuts

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