IF Commons GitHub

logical/closing

Written to: 1 requirement: 1 proved, 0 partly, 0 failing, 0 with no test recorded. 0003-headless-output FR-004

The closing block of a run as data (commons headless 0003-headless-output FR-004): which lines come, in which order, what the verdict says, and the ONE next: command. The surface draws the lines it is given with its own marks and colours; it neither orders nor chooses.

Order: the problems (the first failure is the verdict, so it is not listed twice; then the other failures, then the warnings), what is the person's to do, what is pending, the hints that are due, the steps the command spelled out; then the verdict, then the one next command. The next command is the failure's own, else the first step for the person, else the one the command suggested; a failure whose fix holds no command has none.

import { closingOf } from "./closing.ts";
import { outcomeOf } from "./outcome.ts";
closingOf(outcomeOf(null), { fix: { commands: [], own: [] }, shownHints: [] }).verdict.text; // "Up to date"

Source: commons/headless/src/logical/closing.ts

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

logical.ClosingProblemtypeno test imports it
type ClosingProblem = { readonly kind: "problem"; readonly level: ProblemLevel; readonly message: string; readon… (412 characters)
type ClosingProblem = {
  readonly kind: "problem";
  readonly level: ProblemLevel;
  readonly message: string;
  readonly code?: string;
  readonly say?: string;
  /** The command, labelled `fix` for a failure or a warning and `run` for what is pending or the person's. */
  readonly command?: { readonly label: "fix" | "run"; readonly command: string };
  readonly raw?: string;
  readonly logLine?: number;
};

A problem as a line of the block: its text, its code, the instruction and the one command of its fix.

logical.ClosingHinttypeno test imports it
type ClosingHint = { readonly kind: "hint"; readonly message: string; readonly command?: string };

A hint as a line of the block.

logical.ClosingSteptypeno test imports it
type ClosingStep = { readonly kind: "step"; readonly text: string };

A step the command spelled out.

logical.ClosingLinetypeno test imports it
type ClosingLine = ClosingProblem | ClosingHint | ClosingStep;

One line of the block.

logical.Verdicttypeno test imports it
type Verdict = {
  readonly level: "ok" | "fail" | "cancelled";
  readonly text: string;
  /** The code of the failure that is the verdict. */
  readonly code?: string;
};

The verdict: how the run ended, in one line.

logical.Closingtypeno test imports it
type Closing = {
  readonly lines: readonly ClosingLine[];
  readonly verdict: Verdict;
  /** The instruction of the failure that is the verdict, shown before it. */
  readonly rootSay?: string;
  /** The one next command: only a command, never a sentence. */
  readonly next?: string;
  readonly counts: Counts;
  /** How many hints the block shows. */
  readonly hintsShown: number;
};

The closing block.

logical.ClosingOptionstypeno test imports it
type ClosingOptions = {
  readonly fix: FixCommands;
  /** The title of a verdict where all is well, over the outcome's own. */
  readonly title?: string;
  /** The hints that are due (the cadence is the surface's: `hintsDue`). */
  readonly shownHints: readonly Hint[];
};

What the block depends on besides the outcome.

logical.closingOffunctionno test imports it
function closingOf(o: Outcome, options: ClosingOptions): Closing

The closing block of an outcome.

ClosingProblemtypeno test imports it
type ClosingProblem = { readonly kind: "problem"; readonly level: ProblemLevel; readonly message: string; readon… (412 characters)
type ClosingProblem = {
  readonly kind: "problem";
  readonly level: ProblemLevel;
  readonly message: string;
  readonly code?: string;
  readonly say?: string;
  /** The command, labelled `fix` for a failure or a warning and `run` for what is pending or the person's. */
  readonly command?: { readonly label: "fix" | "run"; readonly command: string };
  readonly raw?: string;
  readonly logLine?: number;
};

A problem as a line of the block: its text, its code, the instruction and the one command of its fix.

ClosingHinttypeno test imports it
type ClosingHint = { readonly kind: "hint"; readonly message: string; readonly command?: string };

A hint as a line of the block.

ClosingSteptypeno test imports it
type ClosingStep = { readonly kind: "step"; readonly text: string };

A step the command spelled out.

ClosingLinetype
type ClosingLine = ClosingProblem | ClosingHint | ClosingStep;

One line of the block.

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

Verdicttypeno test imports it
type Verdict = {
  readonly level: "ok" | "fail" | "cancelled";
  readonly text: string;
  /** The code of the failure that is the verdict. */
  readonly code?: string;
};

The verdict: how the run ended, in one line.

Closingtypeno test imports it
type Closing = {
  readonly lines: readonly ClosingLine[];
  readonly verdict: Verdict;
  /** The instruction of the failure that is the verdict, shown before it. */
  readonly rootSay?: string;
  /** The one next command: only a command, never a sentence. */
  readonly next?: string;
  readonly counts: Counts;
  /** How many hints the block shows. */
  readonly hintsShown: number;
};

The closing block.

ClosingOptionstypeno test imports it
type ClosingOptions = {
  readonly fix: FixCommands;
  /** The title of a verdict where all is well, over the outcome's own. */
  readonly title?: string;
  /** The hints that are due (the cadence is the surface's: `hintsDue`). */
  readonly shownHints: readonly Hint[];
};

What the block depends on besides the outcome.

closingOffunction
function closingOf(o: Outcome, options: ClosingOptions): Closing

The closing block of an outcome.

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

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