A blazing-fast™ command-line tool to recursively count lines of code in a directory, supporting custom glob patterns for file matching. Built with Go, leveraging concurrency for speed and efficiency.
- Recursive directory traversal
- Glob pattern matching for file extensions and paths
- Concurrent processing for fast line counting
- Breakdown of LOC by glob pattern (when multiple patterns are used)
- Lightweight and easy to build and install
- Go installed
-
Clone the repository:
git clone git@github.com:yourusername/count_locs.git cd count_locs
-
Download dependencies:
go mod tidy
-
Build the binary:
go build -o count_locs
-
(Optional) Install Globally:
Move the binary to a directory that's in your PATH. For example:
sudo mv count_locs /usr/local/bin/
-
Verify Installation:
count_locs --help
count_locs <directory> <glob-patterns>...
count_locs . "**/*.go"
count_locs ./ "**/*.go" "**/*.py" "**/*.md"
If multiple glob patterns are provided, you'll see a breakdown:
Breakdown of Lines of Code by Glob:
**/*.go: 1200
**/*.py: 800
**/*.md: 150
Total: 2150 lines of code
Elapsed time: 150ms
If only one glob pattern is used, only the total is shown:
Total: 1500 lines of code
Elapsed time: 100ms
Ensure you have Go installed. You can download it from golang.org.
Build the project with:
go build -o count_locs
You can also run the program without building a binary:
go run main.go <directory> <glob-patterns>...
If tests are provided, run:
go test ./...
A Makefile
is included for convenience. Here are some example targets:
- 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.cls
- Create a feature branch.
- Commit your changes.
- Push to your branch.
- Open a pull request.
This project is licensed under the Unlicense.