IF Commons GitHub

text

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

Small pure text helpers that more than one codebase wrote: line endings made LF, ANSI escapes removed, and a command line split into its argument vector without a shell (0001-core FR-003). Taken from Stolos's fsx.ts and exec.ts and the machine setup's ui.ts.

import { splitArgs } from "./text.ts";
splitArgs(`git commit -m "a message"`); // { kind: "ok", value: ["git", "commit", "-m", "a message"] }

Source: commons/core/src/text.ts

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

ANSIconstno test imports it
const ANSI: RegExp

A control sequence of a terminal (CSI): colour, cursor and erase.

lffunction
function lf(text: string): string

Text with Windows line endings (CRLF, as Git for Windows checks files out) made LF.

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

plainfunction
function plain(text: string): string

Text without its terminal control sequences, as a log or a pipe should keep it.

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

quoteArgsfunction
function quoteArgs(argv: readonly string[]): string

An argument vector as one line a person can read and paste into a POSIX shell: words quoted only where they must be.

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

splitArgsfunction
function splitArgs(line: string): Result<readonly string[], string>

A command line split into its argument vector without a shell: words are separated by white space, and single or double quotes keep a word together (no escapes, no variables, no globbing). An unterminated quote is an error.

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

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