- Workspace root:
Cargo.tomlwith members incrates/*. - Crates:
core— small library exposingpub fn parse_input_file().app— CLI that reads a file and reports its byte length.
- Build:
cargo build - Test:
cargo test - Lint:
cargo clippy --all-targets - Format check:
cargo fmt -- --check
- API:
core::parse_input_file<P: AsRef<Path>>(path) -> io::Result<String>. - Example:
cargo run -p core --example read -- Cargo.toml.
- Usage:
cargo run -p app -- [--input <path>] [--output <file>] [--quiet] [--json]-i, --input <path>: file to read (defaults toCargo.toml).-o, --output <file>: write result to a file (stdout still prints unless--quiet).-q, --quiet: suppress normal output (errors still go to stderr).--json: emit{ "path": "...", "bytes": N }on stdout.-h, --help: show usage.
- Default (reads
Cargo.toml):cargo run -p app --
- Explicit path:
cargo run -p app -- -i crates/core/Cargo.toml
- JSON output:
cargo run -p app -- --json -i Cargo.toml
- Write to file:
cargo run -p app -- --json -i Cargo.toml -o result.json
- Quiet success:
cargo run -p app -- --quiet -i Cargo.toml
- Unit tests live in
crates/core/src/lib.rs. - Integration tests live in
crates/core/tests/. - Error cases covered: nonexistent file, reading a directory, and permission-denied on Unix.