@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
35 lines • 1.57 kB
TypeScript
/**
* A bash builtin's option scan: letters as typed, then operands.
*
* `letters` keeps every option letter in the order it was typed, repeats
* kept, so a builtin whose flags are mutually exclusive can apply bash's
* last-one-wins rule. `bad` is the first invalid option, spelled the way
* the refusal spells it, or null when every letter is known.
*/
export interface OptionScan {
letters: readonly string[];
operands: readonly string[];
bad: string | null;
}
/**
* Scan a bash builtin's leading option letters.
*
* bash builtins take single letters only (bash's own getopt), which is a
* different grammar from the GNU tools `parseShellOptions` serves:
* scanning is non-permuting and stops at `--` or the first non-option
* word, a token carries options only when it starts with a dash and is
* longer than one character, and every character after that dash is a
* letter. A long spelling therefore fails on its second dash, which is
* why bash refuses `type --foo` as `--` and not as `--foo` (pinned
* against bash 5.2, debian:stable-slim).
*/
export declare function scanOptions(args: readonly string[], known: string): OptionScan;
/**
* The last of a mutually exclusive letter group, as bash resolves it.
*
* bash holds such a group in one variable, so the last letter typed
* wins: `type -tp` prints a path and `type -pt` a type word, and
* `command -vV` is verbose where `command -Vv` is not.
*/
export declare function lastOf(letters: readonly string[], choices: string): string | null;
//# sourceMappingURL=getopt.d.ts.map