ANSIconstno test imports itconst ANSI: RegExpA control sequence of a terminal (CSI): colour, cursor and erase.
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"] }ANSIconstno test imports itconst ANSI: RegExpA control sequence of a terminal (CSI): colour, cursor and erase.
lffunctionfunction lf(text: string): stringText with Windows line endings (CRLF, as Git for Windows checks files out) made LF.
plainfunctionfunction plain(text: string): stringText without its terminal control sequences, as a log or a pipe should keep it.
quoteArgsfunctionfunction quoteArgs(argv: readonly string[]): stringAn argument vector as one line a person can read and paste into a POSIX shell: words quoted only where they must be.
splitArgsfunctionfunction 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.