Skip to main content

Crate crossmap_cli

Crate crossmap_cli 

Source
Expand description

The crossmap command, with everything it touches outside its arguments injected so it runs the same under test as from a terminal.

The command is two pure steps around the reading of its arguments: plan reads the command line and either names the sources to read or settles the outcome (help, version, bad usage), and complete takes the texts read (or why each could not be) and produces the outcome. run joins them with a CliIo. A host that reads in its own way (the npm package’s Node shim, which reads through Node’s file system and fetch) calls the two steps and does the reading between them, and so prints exactly what this command prints. The native reader, [read_source], is behind the read feature, so the steps compile without it to wasm32-unknown-unknown.

Re-exports§

pub use read_source::ReadLimits;
pub use read_source::read_source;

Modules§

read_source
Reading the text a command-line argument names: standard input for -, a URL when the argument starts with a scheme, otherwise a file path.

Structs§

Invocation
A command line that names a command and its sources, ready for them to be read.
Outcome
What the command settled on: its exit status and everything it writes to each stream.
StandardStreams
The process’s own standard streams and the real readers: what the crossmap executable runs with, and what any other host of the command (the Python package’s console script) runs with.

Constants§

EXIT_OK
The command did what was asked.
EXIT_REJECTED
The inputs were readable but the library rejected them; the reason is on standard error.
EXIT_USAGE
The command could not run: bad usage, or an argument that is unreadable or not JSON.
STDIN
The argument that stands for standard input.
SUPPORTED_SCHEMES
The URL schemes the command reads, in the order the error for any other scheme lists them.
USAGE
The usage text.
VERSION
The version the command reports.

Traits§

CliIo
Everything the command touches outside its arguments.

Functions§

complete
Finishes the command from what reading its sources gave: reads holds, for each of Invocation::operands in order, the text read or the reason it could not be (which the message names the argument in front of). The first failure in argument order is the one reported.
is_url
Whether an argument names a URL: it starts with a scheme of two or more characters (a letter, then letters, digits, +, - or ., as RFC 3986 allows) and a colon. Two characters at least, so a Windows drive path such as C:\x.json stays a path; the character set admits s3: and git+ssh:, which are reported as unsupported rather than read as file names.
plan
Reads the command line. Ok names the sources to read before complete; Err is the whole outcome when there is nothing to read: the version or the usage text asked for, or bad usage. version is what --version prints.
run
Runs the command and returns its exit status.
scheme_of
The scheme an argument starts with, as written (not lower-cased), when it names a URL.