Skip to main content

Module policy

Module policy 

Source

Structs§

CommandSources
Where a pager or editor takes commands from besides its options: a +word operand, and a standard input that is not a terminal.
FlagPolicy
FlagTolerance
How the dispatcher treats tokens that look like flags but aren’t in the allowlist. unknown controls flag-shaped unknowns; numeric_dash opts into -NUMBER shorthand (e.g. head -20); single_dash_words stops a single-dash token being read as a cluster of short flags, for tools whose options are whole words (exiftool -if is one option that runs Perl, never -i -f). reads_commands.plus is for a pager or editor that runs a +word operand as its first command (less +!id, vim '+!id'): only a line number (+42) or a bare + passes. reads_commands.stdin is for one that reads keystrokes from a standard input that is not a terminal (printf ':!id\n' | vim): fed anything, it is refused.

Enums§

PositionalShape
Predicate over the first positional token of a fallback grammar. Lets a TOML-declared fallback say “the first positional must look like a path” without the handler hardcoding the test.
UnknownTolerance
Whether unrecognized flag-shaped tokens are denied or silently accepted as positional arguments. The default (Strict) makes the allowlist authoritative — any unrecognized -X or --foo is denied.

Traits§

FlagSet

Functions§

check
check_flags
count_positionals
The positional operands check_flags counts, or None where it would refuse a flag.
is_go_local_package
Whether token is a go LOCAL package/file (a filesystem path), as opposed to a module import path. See PositionalShape::GoPackage.
is_local_path
Whether token names a local folder that no tool could read as a remote address. See PositionalShape::LocalPath.
looks_like_path
Heuristic for “this token looks like a file path.” Used by the path PositionalShape. Conservative on purpose — a bare word like Tiltfile is a valid filename in cwd but the heuristic rejects it to avoid swallowing flag-less subcommands. Callers that want bare-name acceptance should match a sub block instead.