Skip to main content

Module strict

Module strict 

Source
Expand description

Strict moreutils-compat mode entry point.

Bypasses clap entirely (clap can’t produce byte-equal moreutils errors) and runs a hand-rolled argv scan that mirrors the documented inputs from the captured moreutils 0.69-1 fixture set:

invocationstdoutstderrexit
sponge -hsponge [-a] <file>: soak up all input from stdin and write it to <file> + LF0
sponge -x (unknown letter)sponge: invalid option -- 'x'\n0
sponge file (success)0
sponge -a file (append)0
sponge dir/ (target=dir)error opening output file: Is a directory\n1

Per STF-003 (autopilot option A): for any unknown long-form input like --some-flag, we emit ONLY the first unknown-option error and continue (one line). moreutils’ POSIX getopt iterates per-character producing up to N errors; we accept the documented divergence rather than carry a custom getopt-style scanner.

Functions§

pre_scan_strict_flag
Pre-clap scan for --strict / --no-strict so the binary can decide whether to enter run before clap gets a chance to print its own help/version messages. Returns Some(true) for --strict, Some(false) for --no-strict, None otherwise. The last occurrence wins.
run
Strict-mode entry. Returns the process exit code.