Skip to content

provenance

Parse recorded command invocations without accessing their historical files.

command_arguments(invocation, command, option_arity)

Return positional arguments and remaining option tokens in recorded order.

Quoted values, interspersed options, equals syntax, and -- are supported.

Parameters:

Name Type Description Default
invocation str

Recorded shell command, including its executable and arguments.

required
command tuple[str, ...]

Nonempty tuple of executable basename and subcommand names.

required
option_arity Mapping[str, bool]

Recognized option names mapped to True for options consuming one value or False for switches consuming no value.

required

Returns:

Type Description
tuple[list[str], list[str]] | None

A pair of lists: positional arguments and the remaining option tokens,

tuple[list[str], list[str]] | None

preserving order within each list. Option values use separate tokens

tuple[list[str], list[str]] | None

(--count=2 becomes ["--count", "2"]). The -- delimiter is omitted.

tuple[list[str], list[str]] | None

Returns None for unknown options, missing option values, malformed

tuple[list[str], list[str]] | None

quoting, or an invocation that does not match the command. Does not

tuple[list[str], list[str]] | None

validate positional argument counts, values, or historical file paths.

command_tokens(invocation, command)

Return arguments following an exact command, allowing an executable path.

Parameters:

Name Type Description Default
invocation str

Recorded shell command, including its executable and arguments.

required
command tuple[str, ...]

Nonempty tuple of executable basename and subcommand names, such as ("protein-detective", "powerfit", "run").

required

Returns:

Type Description
list[str] | None

Shell-tokenized arguments after the matched command, without its

list[str] | None

executable or subcommands. Returns None when quoting is malformed or

list[str] | None

the command is absent. No file or argument-value validation is performed.