@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
31 lines • 1.49 kB
TypeScript
import type { CompiledSpec } from './compile.ts';
export interface OldStyleArgv {
argv: string[];
origins: number[];
needsValue: string | null;
}
/**
* Rewrite GNU tar's old option style into ordinary dashed flags.
*
* tar's first word, when it carries no leading dash, is a cluster of
* option letters whose arguments follow it as separate words in letter
* order: `tar xzCf dir a.tgz` is `-x -z -C dir -f a.tgz`. Only the first
* word reads this way, which is GNU's own rule (`tar -v czf a.tgz f` is
* a usage error), so a line that already starts with a dash is returned
* untouched.
*
* Per letter, not one `-xzCf` token, because the getopt cluster rules
* cannot express what a tar cluster can: it may hold several
* argument-taking letters (`tar cvfb a.tar 20 f`) and it may continue
* past one (`tar cfz a.tgz f` gzips, where getopt would read `z` as f's
* value). An argument is taken verbatim, dash or not, the way GNU does:
* `tar xzf -C ex` looks for an archive literally named `-C`.
*
* An undeclared letter becomes an undeclared flag token and is refused
* by the parser's own scan, so this only reports the one error getopt
* cannot see: a value letter with nothing left to consume. Pair options
* are not expanded here; no tool spells old style and a two-token option
* at once. Mirrors Python's `expand_old_style`.
*/
export declare function expandOldStyle(cs: CompiledSpec, argv: string[]): OldStyleArgv;
//# sourceMappingURL=oldstyle.d.ts.map