IF Commons GitHub

logical/fix

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

A fix text split into the one command in it and the words around it (commons headless 0003-headless-output FR-005): a fix:, run: or next: line holds only the command, so that a person can copy it whole; any instruction goes on a line of its own.

Which words begin a command is the program's: it gives its own name and the tools its fixes call (git, sudo).

import { fixSplitter } from "./fix.ts";
const split = fixSplitter({ commands: ["mytool", "git"], own: ["mytool"] });
split("mytool sync (pull first)"); // { cmd: "mytool sync", say: "Pull first" }
split("Plug it in"); // { say: "Plug it in" }

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

1 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.

logical.FixCommandstypeno test imports it
type FixCommands = {
  /** Programs a whole fix may begin with (`mytool`, `git`, `sudo`). */
  readonly commands: readonly string[];
  /** The program's own commands, found inside a sentence ("then run mytool sync"). */
  readonly own: readonly string[];
};

The words a fix is read for: the programs a whole fix may be a command of, and the program's own, which may stand inside a sentence.

logical.SplitFixtypeno test imports it
type SplitFix = { readonly say?: string; readonly cmd?: string };

The instruction and the command of a fix: each may be absent.

logical.fixSplitterfunctionno test imports it
function fixSplitter(commands: FixCommands): (fix: string | undefined) => SplitFix

A function that splits a fix, for the commands given.

FixCommandstypeno test imports it
type FixCommands = {
  /** Programs a whole fix may begin with (`mytool`, `git`, `sudo`). */
  readonly commands: readonly string[];
  /** The program's own commands, found inside a sentence ("then run mytool sync"). */
  readonly own: readonly string[];
};

The words a fix is read for: the programs a whole fix may be a command of, and the program's own, which may stand inside a sentence.

SplitFixtypeno test imports it
type SplitFix = { readonly say?: string; readonly cmd?: string };

The instruction and the command of a fix: each may be absent.

fixSplitterfunction
function fixSplitter(commands: FixCommands): (fix: string | undefined) => SplitFix

A function that splits a fix, for the commands given.

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

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