A tiny Rust CLI for counting lines in a file or across a directory tree.
- Counts lines in a single file
- Counts total lines across a directory recursively
- Skips
.gitandtargetdirectories when scanning folders - Treats files with NUL bytes as non-text during directory scans and counts them as
0 - Uses a small amount of parallelism for larger directory scans
- Rust and Cargo installed
cargo build --releaseThe compiled binary will be available at:
target/release/lineslines [file-or-directory]If you do not pass a path, lines counts the current working directory.
Count the current directory:
cargo run --releaseCount a specific directory:
cargo run --release -- srcCount a single file:
cargo run --release -- src/main.rsRun the built binary directly:
./target/release/lines .1234 total lines in /path/to/project
187 lines in src/main.rs
- Directory mode is recursive.
- Single-file mode counts the file directly.
- Passing more than one argument returns a usage error.
cargo test