IF Commons GitHub

surfaces/cli/launcher

Written to: 1 requirement: 1 proved, 0 partly, 0 failing, 0 with no test recorded. 0004-headless-cli FR-013

The helpers of a launcher (commons headless 0004-headless-cli FR-013): the program that starts the program, and may find that it cannot. A failure to start is typed, and each kind has its status in the range sysexits.h reserves (64 to 78), apart from the statuses of a run (0 to 4): a service manager, a shell and a person can tell "it could not start" from "it ran and found something". It is written as one line, program: reason, and one fix: line where there is a fix, and nothing else.

import { formatStartupFailure, startupExit } from "./launcher.ts";
startupExit({ kind: "config", message: "tool.toml has no [server]" }); // 78
formatStartupFailure("tool", { kind: "osfile", message: "tool.toml is missing", fix: "tool init" }); // "tool: tool.toml is missing\nfix: tool init\n"

Source: commons/headless/src/surfaces/cli/launcher.ts

3 of 5 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.

StartupKindtypeno test imports it
type StartupKind = "usage" | "unavailable" | "software" | "osfile" | "config";

Why a program could not start.

STARTUP_KINDSconst
const STARTUP_KINDS: readonly StartupKind[]

Every kind.

Imported by 5 tests of the run (5 passed, 0 failed): the library's results

StartupFailuretypeno test imports it
type StartupFailure = {
  readonly kind: StartupKind;
  /** What is wrong, in a plain sentence. */
  readonly message: string;
  /** One command that fixes it, where there is one. */
  readonly fix?: string;
};

A failure to start.

startupExitfunction
function startupExit(f: StartupFailure): number

The status a failure to start ends the program with.

Imported by 5 tests of the run (5 passed, 0 failed): the library's results

formatStartupFailurefunction
function formatStartupFailure(program: string, f: StartupFailure): string

What a failure to start writes: program: message, and fix: command where it has one; both end in a newline.

Imported by 5 tests of the run (5 passed, 0 failed): the library's results

Titles, headings, exports, tables, columns and requirements. Esc closes.