❯ go-clikit
v0.10.0 pkg.go.dev ↗

concepts › the program decides

The program decides

The kit knows no program. A name, a noun, the exit codes, the environment and the signals stay in the program, behind parameters and hooks.

The kit is shared by programs with other names, other targets and other rules for their exit codes. So the kit decides nothing that a program must decide. What depends on a program is a parameter or a hook.

The programos.Getenv("NO_COLOR"), TERM--progress, CLUSTERCTL_PROGRESSsignal.NotifyContext(SIGINT)"hosts", "clusterctl"exit codes, os.Exitits paths, its versionThe kitThemeFor(t, onTerminal, getenv)Options.Mode, Options.Logthe end of a contextOptions.Noun, .ProgramClassify, Coded, Statusfsutil, BuildInfo
What the program reads and decides, and what it hands the kit.

What the kit never does#

  • It reads no environment. Whether to draw in colour, NO_COLOR and TERM included, is the program’s to decide. cliprogress is told what the program read.
  • It sets nothing process-wide. It installs no signal handler and sets no global, such as the default logger.
  • It ends no process. An error goes back to the program, which picks the exit status.

The linter refuses the calls that read or set the environment, handle signals or end the process, outside the tests (decision 21).

The hooks#

What the program decidesWhere it tells the kit
Its name, in a line that says something panickedBusOptions.Program, cliprogress.Options.Program
The noun for its targets: “1 host”, “480 hosts”PlainOptions.Noun, MapOptions.Noun, cliprogress.Options.Noun
The class of an error, for its exit codesprogress.BusOptions.Classify, MapOptions.Classify
The exit status of an errorcobratree.Coded where the cause is known, cobratree.Status in main
The usage errors, for their exit statuscobratree.Usage, cobratree.IsUsage
The flag and variable that pick a display and a logcliprogress.Options.Mode and .Log, a cliprogress.Setting each
Whether standard error is a terminal, its size, the localecliprogress.Options.OnTerminal, .Size, .ASCII
The theme, and the colourscliprogress.ThemeFor
The interruptthe end of the context given to cliprogress.Start
The trace another program handed onprogress.ParseTraceContext of what the program read from TRACEPARENT
Where its files live, and how long it waits for a lockthe paths it passes fsutil, the wait it passes fsutil.Lock
The checks of doctor, and the exit status of a failed onedoctor.Write and doctor.Worst

The architecture has the whole table, for every package.