@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
99 lines • 3.31 kB
TypeScript
import { CommandSpec } from './types.ts';
export declare const SHELL_SPECS: Readonly<Record<string, CommandSpec | undefined> & {
xargs: CommandSpec;
timeout: CommandSpec;
man: CommandSpec;
'(( ... ))': CommandSpec;
'.': CommandSpec;
':': CommandSpec;
'[': CommandSpec;
'[[ ... ]]': CommandSpec;
alias: CommandSpec;
break: CommandSpec;
case: CommandSpec;
cd: CommandSpec;
command: CommandSpec;
continue: CommandSpec;
declare: CommandSpec;
disown: CommandSpec;
echo: CommandSpec;
eval: CommandSpec;
exec: CommandSpec;
exit: CommandSpec;
export: CommandSpec;
false: CommandSpec;
fg: CommandSpec;
for: CommandSpec;
'for ((': CommandSpec;
function: CommandSpec;
getopts: CommandSpec;
help: CommandSpec;
history: CommandSpec;
if: CommandSpec;
jobs: CommandSpec;
kill: CommandSpec;
let: CommandSpec;
local: CommandSpec;
mapfile: CommandSpec;
printf: CommandSpec;
pwd: CommandSpec;
read: CommandSpec;
readarray: CommandSpec;
readonly: CommandSpec;
return: CommandSpec;
select: CommandSpec;
set: CommandSpec;
shift: CommandSpec;
shopt: CommandSpec;
source: CommandSpec;
test: CommandSpec;
time: CommandSpec;
trap: CommandSpec;
true: CommandSpec;
type: CommandSpec;
typeset: CommandSpec;
umask: CommandSpec;
unalias: CommandSpec;
unset: CommandSpec;
until: CommandSpec;
wait: CommandSpec;
while: CommandSpec;
'{ ... }': CommandSpec;
}>;
/**
* Result of a strict leading-option scan for a shell builtin.
*
* Wrapper builtins (xargs, timeout) stop option parsing at the first
* operand, since everything after it belongs to the wrapped command;
* the mount-command parser scans the whole line and warns-ignores
* unknown flags, which is wrong on both counts here. The builtin owns
* the error message and exit code (GNU shapes differ per tool), so
* the parse only reports what went wrong. An optional-value option given
* bare is `true` in `flags`; `given` lists every option in the order it
* was given, for a builtin whose options act in turn (xargs -I, -L and
* -n cancel one another). `candidates` names the long options an
* ambiguous abbreviation in `invalid` could mean, in declaration order,
* and is empty when `invalid` names none. `needsValue` is the short
* char, or the long token with its dashes; `unexpectedValue` is a
* no-argument long option given a value, as its full spelling and the
* value (`--null=x`).
*/
export interface ShellParse {
flags: Record<string, string | boolean>;
given: [string, string | boolean][];
operands: string[];
invalid: string | null;
candidates: readonly string[];
needsValue: string | null;
unexpectedValue: string | null;
}
/**
* Scan leading options the way getopt does for a shell builtin.
*
* An optional-value option takes its value only when attached (`-iR`,
* `--replace=R`), as getopt's `::` does, and a long option may be
* abbreviated to any prefix that names one option, as getopt_long reads
* it; an empty name (`--=x`) prefixes every one.
*/
export declare function parseShellOptions(spec: CommandSpec, argv: readonly string[]): ShellParse;
//# sourceMappingURL=shell.d.ts.map