feat(cli): add a Rust anydoc binary for cargo install

LE
2mo ago
+340-1

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.js line for line rather than pulling in clap; --format validates through the existing Format::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-level ConvertError::Io message doesn't carry it, and on the CLI the filename is the useful part.
  • Cargo.toml needs 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 anydoc in the CLI section.

Testing:

  • tests/cli.rs drives the built binary end to end via CARGO_BIN_EXE_anydoc: file conversion, stdin with a named format, --format=csv inline form, alias resolution, --output, and every usage-error path (15 tests).
  • cargo fmt --check, cargo clippy --workspace --all-targets --all-features -- -D warnings, and cargo test --locked all 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 80 exits 0 on the closed pipe.

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.