Skip to content

alanrsoares/count_locs.rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🦀 Count LOCs 🦀

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.

Features

  • 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

Installation

Prerequisites

Steps

  1. Clone the repository:

    git clone git@github.com:alanrsoares/count_locs.rs.git
    cd count_locs
  2. Build and install the binary:

    cargo install --path . --force
  3. Ensure ~/.cargo/bin is in your PATH:

    export PATH="$HOME/.cargo/bin:$PATH"
  4. Verify installation:

    count_locs --help

Usage

Basic Command

count_locs <directory> <glob-patterns>...

Examples

Count all Rust files in ./src:

count_locs ./src "**/*.rs"

Count all TypeScript, TSX, and CSS files in a project:

count_locs ./ "**/*.ts" "**/*.tsx" "**/*.css"

Example Output:

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

Development

Prerequisites

Ensure you have Rust installed. Use rustup to manage your Rust installation:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Build

cargo build --release

Run Tests

cargo test

Install Locally for Development

cargo install --path . --force

Makefile Support

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

Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository.
  2. Create a feature branch.
  3. Commit your changes.
  4. Push to your branch.
  5. Open a pull request.

License

This project is licensed under the Unlicense.

About

Blazing-fast™️ CLI tool to count lines of code with glob pattern support, built in Rust 🦀.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published