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:
| invocation | stdout | stderr | exit |
|---|---|---|---|
sponge -h | sponge [-a] <file>: soak up all input from stdin and write it to <file> + LF | — | 0 |
sponge -x (unknown letter) | — | sponge: invalid option -- 'x'\n | 0 |
sponge file (success) | — | — | 0 |
sponge -a file (append) | — | — | 0 |
sponge dir/ (target=dir) | — | error opening output file: Is a directory\n | 1 |
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-strictso the binary can decide whether to enterrunbefore clap gets a chance to print its own help/version messages. ReturnsSome(true)for--strict,Some(false)for--no-strict,Noneotherwise. The last occurrence wins. - run
- Strict-mode entry. Returns the process exit code.