cli

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: MIT Imports: 28 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package cli is the command line of mtqg: it reads the arguments, calls the core, and shows the result.

It is the only place where mtqg speaks: every sentence it prints is English and lives in messages.go, and the core below it returns kinds of error and structured results instead (.claude/rules/cli-output.md). Run takes everything it touches in an Env (the streams, the environment variables, the clock, the terminal), so that tests call it directly.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(env Env, args []string) int

Run runs mtqg with the given arguments (without the name of the program) and returns the exit code.

Types

type Env

type Env struct {
	Stdin  io.Reader
	Stdout io.Writer
	Stderr io.Writer

	// Getenv returns an environment variable, empty when it is not set.
	Getenv func(string) string

	// Getwd returns the current directory.
	Getwd func() (string, error)

	// Now returns the current time. Location is where times are shown.
	Now      func() time.Time
	Location *time.Location

	// StdoutIsTerminal says that standard output is a terminal, not a pipe or a
	// file. Only then is text cut to the width of the window and color used.
	StdoutIsTerminal bool

	// StdoutWidth is the width of the terminal window in columns, or 0 when it is
	// not known.
	StdoutWidth int

	// ANSI says that the terminal understands color codes.
	ANSI bool

	// TTY names the terminal that the command was typed at, for undo to tell one
	// terminal from another: "dev:" and the device number of the first of standard
	// input, output and error that is a terminal. Empty when there is none, and
	// always on Windows. It is never written as it is: terminalID hashes it.
	TTY string

	// ReadFile reads a file. It is what format is given as an argument.
	ReadFile func(name string) ([]byte, error)

	// RunEditor runs an editor, given as the command and its arguments, with the
	// terminal attached, and returns when the editor has exited.
	RunEditor func(argv []string) error

	// Version is the version the release build set (cmd/mtqg's main.version, the
	// tag as v0.1.0), or empty: then it comes from the build information.
	Version string
}

Env is everything Run touches outside the arguments. cmd/mtqg fills it from the operating system (OSEnv); tests fill it with buffers and fixed values.

func OSEnv

func OSEnv() Env

OSEnv is the Env of the running program: the real streams, environment, clock and terminal.

Jump to

Keyboard shortcuts

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