command

package
v0.0.0-...-e08afc0 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2026 License: AGPL-3.0 Imports: 41 Imported by: 0

Documentation

Overview

Package command is the yupsh command catalogue: the registry mapping each command keyword to how its flags are parsed and how its pipeline segment is built from the gloo-foo/cmd-* modules.

Each registry entry is a Builder: a flag table (a flags.Set), a BuildFunc that turns parsed positionals and options into a Segment, an optional raw passthrough mode for commands whose arguments are literal text, and a one-line summary for help output. A Segment is the built form of one pipeline stage — a source, a transform command, and at most one input source (files or literal inputs). The package knows how to construct commands; it does not run them (that is internal/pipeline) nor orchestrate a line (that is the line domain).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Registry

func Registry() map[Name]Builder

Registry returns the command table. It is built fresh per caller so callers never share mutable state.

Types

type BuildFunc

type BuildFunc func(fs afero.Fs, positional flags.Argv, opts []any) (Segment, error)

BuildFunc constructs a Segment from a command's positional arguments and the already-parsed flag options. The filesystem is injected for the commands (ls, find) that build against it.

type Builder

type Builder struct {
	Flags   flags.Set
	Build   BuildFunc
	Raw     bool
	Summary string
}

Builder is a registry entry: how to parse a command's flags, how to build its segment, and a one-line summary for help output. When Raw is set, flag parsing is skipped and every token is passed through as a positional — used by commands whose arguments are literal text (echo, yes, emit) or belong to an external program (git, exec).

type Name

type Name string

Name is a command keyword typed at the prompt (e.g. "grep").

type Segment

type Segment struct {
	Source  gloo.Source[[]byte]
	Command gloo.Command[[]byte, []byte]
	Files   []gloo.File
	Inputs  [][]byte
}

Segment is the built form of one pipeline stage. A source segment sets Source and no command. A filter segment sets Command and, optionally on the first stage, an input source: Files are opened from the filesystem, while Inputs are used verbatim as input lines (for path processors like basename whose arguments are data, not filenames). At most one of Files or Inputs is set.

Jump to

Keyboard shortcuts

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