IF Commons GitHub

cli

Written to: 1 requirement: 1 proved, 0 partly, 0 failing, 0 with no test recorded. 0001-docs FR-003

The parts of the command line of the documentation generator, ifc-docs (commons 0011-documentation FR-003, FR-023): ifc-docs build [--out DIR] writes the site into DIR (the configuration's out by default, _site at the repository's root unless it says otherwise); ifc-docs check builds it into a temporary folder, prints every finding as where: message on standard error, writes nothing in the repository, and exits 1 where there is one. Both read the configuration given by --config FILE, or else the first docs.config.ts found from the working folder up to the repository's root. A command line or a configuration that is not valid is refused with exit status 2. It runs on Bun, the runtime of record, and on Node 26; in commons, bun main.ts build and bun main.ts check in commons/docs/ run it from the source.

Source: commons/docs/src/cli.ts

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

Commandtypeno test imports it
type Command = | { readonly kind: "build"; readonly out: string | undefined; readonly config: string | und… (465 characters)
type Command =
  | {
    readonly kind: "build";
    readonly out: string | undefined;
    readonly config: string | undefined;
    /** The presentations asked for; the configuration's where none. */
    readonly presentations?: readonly PresentationId[];
    /** Write nothing: say which files are not what a build would write. */
    readonly verify?: boolean;
  }
  | { readonly kind: "check"; readonly config: string | undefined }
  | { readonly kind: "help" };

What the command line asks for.

findConfigfunction
function findConfig(from: string): string | undefined

The configuration's file: the first docs.config.ts from a folder up to the repository's root (the first folder that holds .git).

ParameterWhat it is
fromthe folder to start from

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

loadConfigfunction
function loadConfig(file: string): Promise<Result<Config, string[]>>

A configuration's module loaded and checked: its default export, or its export config.

ParameterWhat it is
filethe configuration's file

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

mainfunction
function main(args: readonly string[], cwd?: string): Promise<number>

The generator run: the site built, written or checked; the exit status (0, 1 where check finds something, 2 where it is refused).

ParameterWhat it is
argsthe command line's arguments
cwdthe working folder, where the search for the configuration starts

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

parseArgsfunction
function parseArgs(args: readonly string[]): Result<Command, string>

The command a command line asks for, or why it is not one.

ParameterWhat it is
argsits arguments

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

USAGEconstno test imports it
const USAGE: string

The usage, printed by --help and with a refusal.

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