Skip to main content

Module cli

Module cli 

Source
Expand description

The command line: argument parsing, file walking, reporting, exit codes.

The parity boundary is exit codes and stdout, byte for byte; stderr need only match in meaning, which is why the error prose here is not a translation of Python’s. corpus/cli/ judges all three.

The parser reproduces argparse’s contract rather than inventing one, and every behavior below was measured against CPython rather than recalled: unambiguous long-option abbreviation, --opt=value, -- ending the option list without breaking the positional run, a lone - as a positional, and a token starting with - being a positional when it looks like a negative number or contains a space.

One argparse behavior is deliberately not reproduced exactly. See [is_negative_number].

Structs§

Args
The parsed command line.
Outcome
What one run of the program produced.

Functions§

parse_args
Parse argv, or return the message a parse failure would print.
posix_display
Path(raw).as_posix(): how a path is reported, on every platform.
run
Run the program and return everything it would have written.
working_directory
The working directory, or . when it cannot be read.