feat(cli): add a Rust anydoc binary for cargo install
LE
2mo ago+340+340+012345678901234567890123456789-1-1-0123456789
Closes #24.
Adds src/bin/anydoc.rs so cargo install anydoc yields the same CLI the npm package ships. The two front ends stay interchangeable — same options (-o/--output, -f/--format, -h, -V, --, - for stdin, --opt=value inline form), same help text, same exit codes (0 success / 1 conversion / 2 usage), and the same tolerances: stdin-on-a-TTY is a usage error, early-closed stdout (anydoc big.xlsx | head) exits 0.
Design notes:
- No new dependencies. Argument parsing is hand-rolled to mirror
node/cli.jsline for line rather than pulling in clap;--formatvalidates through the existingFormat::from_extension, so extension aliases (xls,docm,ppsx, …) resolve identically to the npm CLI. - The one deliberate divergence: when a file can't be read, the error names the path (
anydoc: report.docx: No such file or directory…) — the library-levelConvertError::Iomessage doesn't carry it, and on the CLI the filename is the useful part. Cargo.tomlneeds no changes: the bin is auto-discovered,include = ["/src", …]already packages it, and library consumers (cargo add) never build it.- README gains a half-sentence pointing at
cargo install anydocin the CLI section.
Testing:
tests/cli.rsdrives the built binary end to end viaCARGO_BIN_EXE_anydoc: file conversion, stdin with a named format,--format=csvinline form, alias resolution,--output, and every usage-error path (15 tests).cargo fmt --check,cargo clippy --workspace --all-targets --all-features -- -D warnings, andcargo test --lockedall pass locally (182 lib + 15 CLI + snapshot/robustness suites).- Manually verified: docx/epub/csv fixtures convert byte-identically to the npm CLI paths, and
anydoc - --format csv < big.csv | head -c 80exits 0 on the closed pipe.
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.