A blazing-fast™️ command-line tool to recursively count lines of code in a directory, supporting custom glob patterns for file matching. Built with Rust, leveraging parallel processing for speed and efficiency.
- Recursive directory traversal
- Glob pattern matching for file extensions and paths
- Parallel processing for fast line counting
- Breakdown of LOC by glob pattern (when multiple patterns are used)
- Lightweight and easy to install as a global binary
- Rust installed (Install Rust)
-
Clone the repository:
git clone git@github.com:alanrsoares/count_locs.rs.git cd count_locs
-
Build and install the binary:
cargo install --path . --force
-
Ensure
~/.cargo/bin
is in yourPATH
:export PATH="$HOME/.cargo/bin:$PATH"
-
Verify installation:
count_locs --help
count_locs <directory> <glob-patterns>...
count_locs ./src "**/*.rs"
count_locs ./ "**/*.ts" "**/*.tsx" "**/*.css"
Breakdown of Lines of Code by Glob:
**/*.ts: 1200
**/*.tsx: 800
**/*.rs: 1500
Total lines of code: 3500
If only one glob pattern is used, the breakdown will be omitted:
Total lines of code: 1500
Ensure you have Rust installed. Use rustup
to manage your Rust installation:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
cargo build --release
cargo test
cargo install --path . --force
A Makefile
is included for convenience:
- Build the project:
make build
- Run tests:
make test
- Install globally:
make install
- Clean build artifacts:
make clean
- Run the binary:
make run
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create a feature branch.
- Commit your changes.
- Push to your branch.
- Open a pull request.
This project is licensed under the Unlicense.