cli

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2026 License: BSD-3-Clause Imports: 27 Imported by: 0

Documentation

Overview

Package cli is the headwire command line shared by every program: the headwire binary adds run, and Headwire.app adds its profile and GUI verbs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadConfig

func LoadConfig(
	args []string,
	stderr io.Writer,
	usage func(io.Writer),
) (*config.Config, string, int)

LoadConfig loads the configuration a command's optional NAME or FILE argument selects. It returns a nil config with the exit code to use when the command should not run.

func LogWriter

func LogWriter(stderr io.Writer) io.Writer

LogWriter applies LOG_LEVEL to the engine's output: the default hides tailscale's [v1]/[v2] verbose lines, verbose/debug keep them, silent drops everything. headwire's own lines carry no marker.

func Run

func Run(args []string, stdin io.Reader, stdout, stderr io.Writer, p Program) int

Run executes args and returns the exit code.

Types

type Command

type Command struct {
	Args string // after the name in its usage line, holding the whole argument vocabulary
	Run  RunFunc
}

Command is one entry of the command table. A nil Run is a command the program dispatches itself before calling Run, so reaching it is a usage error.

func ConfigCommand

func ConfigCommand(run RunFunc) Command

ConfigCommand is a command that loads its configuration with LoadConfig.

type Program

type Program struct {
	Usage    string // lines listing the program's commands after the shared ones
	Commands map[string]Command
	Request  func(string) (string, error) // one request to the running node
}

Program adds its own commands and request transport to the shared ones.

type RunFunc

type RunFunc func(args []string, stdout, stderr io.Writer, usage func(io.Writer)) int

RunFunc runs a command with the arguments after its name. usage prints the command's own usage.

Jump to

Keyboard shortcuts

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