import type { GameState } from "./types.ts"; /** * The command line, as a pure function: arguments and surroundings in, what * to print and the exit code out. `bin/narabe.mjs` is the few lines that hand * it the real process. Nothing here touches a file, a terminal or the * network, so every line of it is tested as plain data, and nothing here is a * rule: every move is made, and every result decided, by the engine. */ /** What the command line is run in. All of it is optional. */ export type CliSurroundings = { /** The environment, for the language (`LC_ALL`, `LC_MESSAGES`, `LANG`). */ env?: Record; /** Standard input, when `--stdin` asks for it: a saved game. */ stdin?: string; /** Reads a file named on the command line, or gives null when it cannot be read. */ readFile?: (path: string) => string | null; /** The system's language where the environment names none: what `Intl` says, on Windows. */ locale?: string; /** Where a seed comes from when none is given: a function that returns a whole number from 1. The engine never draws one itself, so `bin/narabe.mjs` hands in one made from `Math.random`; without it the seed is 1. */ seed?: () => number; }; /** What the command line came to. */ export type CliResult = { /** 0 when all went well, 1 when what was asked for could not be done, 2 when the command itself was wrong. */ code: 0 | 1 | 2; /** For standard output. */ out: string; /** For standard error. */ err: string; }; /** The languages the command line speaks. */ export type CliLanguage = "en" | "ja"; /** Every word the command line says, in both languages. `{n}` and the other braces are filled in when shown. */ export declare const CLI_STRINGS: Record>; /** The language the command line speaks: `--lang`, or the environment's, or the system's; Japanese for `ja…`, English for anything else. */ export declare function cliLanguage(flag: string | undefined, env?: Record, locale?: string): CliLanguage; /** The board as text: column letters across the top, row numbers down the side, X for Black and O for White. The hexagon-lattice games slide each row half a cell, as they are drawn. */ export declare function boardText(state: GameState): string; /** Run the command line. See `narabe --help` for what it takes. */ export declare function runCli(args: readonly string[], around?: CliSurroundings): CliResult;