ccloc - Count Lines of Code
A simple and fast CLI tool to count lines of code in your projects, built with Python and managed by uv.
Features
- 📊 Count lines of code by file extension/language
- 🎯 Filter by specific file extensions
- 🚫 Exclude directories and files
- 📈 Beautiful table output with Rich
- 📄 Multiple output formats (table, JSON, CSV)
- ⚡ Fast and efficient
- 🎨 Automatic comment and blank line detection
Installation
Using uv (recommended)
uv pip install ccloc
Using pip
pip install ccloc
From source
git clone https://github.com/chuongmep/ccloc.git
cd ccloc
uv sync
Usage
Basic usage
Show usage/help (default when no arguments):
ccloc
Count lines in the current directory:
ccloc .
Count lines in a specific directory:
ccloc /path/to/project
Filter by file extensions
Count only Python files:
ccloc --extensions .py
# or
ccloc -e .py
Count Python and JavaScript files:
ccloc -e .py -e .js -e .ts
Exclude directories
Exclude specific directories (by default excludes: .git, .venv, node_modules, __pycache__):
ccloc -x build -x dist
Output formats
Table format (default):
ccloc .
JSON format:
ccloc --format json
# or
ccloc -f json
CSV format:
ccloc -f csv > output.csv
Recursive scanning
By default, the tool recursively scans all subdirectories. You can disable this:
# Scan only top-level directory
ccloc --no-recursive
# Scan only top-level Python files
ccloc --no-recursive -e .py
Combined examples
Count Python and JavaScript files, excluding tests:
ccloc -e .py -e .js -x tests -x __tests__
Scan only current directory without recursion:
ccloc . --no-recursive
Count all code in a project with JSON output:
ccloc /path/to/project -f json
Output
The tool provides detailed statistics:
- Files: Number of files for each language/extension
- Lines: Total lines in files
- Blank: Blank lines
- Comment: Comment lines
- Code: Actual code lines (Lines - Blank - Comment)
Example output:
Lines of Code
┏━━━━━━━━━━━━━━━━━━━━┳━━━━━━━┳━━━━━━━┳━━━━━━━┳━━━━━━━━━┳━━━━━━━┓
┃ Language/Extension ┃ Files ┃ Lines ┃ Blank ┃ Comment ┃ Code ┃
┡━━━━━━━━━━━━━━━━━━━━╇━━━━━━━╇━━━━━━━╇━━━━━━━╇━━━━━━━━━╇━━━━━━━┩
│ .py │ 5 │ 1234 │ 123 │ 111 │ 1000 │
│ .js │ 3 │ 567 │ 45 │ 66 │ 456 │
├────────────────────┼───────┼───────┼───────┼─────────┼───────┤
│ TOTAL │ 8 │ 1801 │ 168 │ 177 │ 1456 │
└────────────────────┴───────┴───────┴───────┴─────────┴───────┘
Development
This project uses uv for dependency management.
Setup development environment
# Clone the repository
git clone https://github.com/chuongmep/ccloc.git
cd ccloc
# Install dependencies
uv sync
# Run the tool in development mode
uv run ccloc
Run tests
uv run pytest
Build package
uv build
Supported Languages
The tool automatically detects comments for:
- Python (
.py) - JavaScript/TypeScript (
.js,.ts) - Java (
.java) - C/C++ (
.c,.cpp) - C# (
.cs) - Go (
.go) - Rust (
.rs) - PHP (
.php) - Ruby (
.rb) - Shell scripts (
.sh) - YAML (
.yaml,.yml)
And many more! Files with any extension can be counted.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
MIT License - see LICENSE file for details
Author
Chuong Ho - chuongpqvn@gmail.com
Metadata
Release files for ccloc 0.1.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ccloc-0.1.6.tar.gz | 7.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ccloc-0.1.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 15.6 kB
Release files / ccloc-0.1.6.tar.gz
| Download URL | ccloc-0.1.6.tar.gz |
|---|---|
| Size | 7.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5e58bf04546181b50e4b57fbf6391da673d4ebc57f8eae5afb55420550edd391
|
|
BLAKE2b-256 checksum How to use checksums |
92a668c81491d337806abd668999cf563d2d215934d9370a43f292a6b64fa7ec
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / ccloc-0.1.6-py3-none-any.whl
| Download URL | ccloc-0.1.6-py3-none-any.whl |
|---|---|
| Size | 8.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
81d2cf1b1904d9b5b5ebf50a735182d8e5537066d03cdfb3ae185881fe429897
|
|
BLAKE2b-256 checksum How to use checksums |
7ebdd17a3f8b00bef0d94d99c02396910942c65b16ef23b89ef2372c33095355
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|