Skip to main content

Just Count Total Line Of Code

Project description

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/yourusername/cloc.git
cd cloc
uv sync

Usage

Basic usage

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/cloc.git
cd cloc

# 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ccloc-0.1.0.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ccloc-0.1.0-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file ccloc-0.1.0.tar.gz.

File metadata

  • Download URL: ccloc-0.1.0.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using 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}

File hashes

Hashes for ccloc-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9d3b6290835063526a776bdc4a88e4bd245b0cf5a5536bc6d193665214ffc0a0
MD5 a1f0faa4a8b0c86e27a868bee33099d2
BLAKE2b-256 21330fcc662f10944ec8d91c6530dbf14a4274f60105797655ccab78a3b95945

See more details on using hashes here.

File details

Details for the file ccloc-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: ccloc-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.4 kB
  • Tags: Python 3
  • Uploaded using 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}

File hashes

Hashes for ccloc-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 22dec9fae37d7f9eb4bc9313bf4e6d5898529d2013e8a8c4a7ba05177e60e2c5
MD5 fea68f107837484b99ad950b9d37eafa
BLAKE2b-256 5c29459e9bfdda9cf8be4718f3f7ccdfe30e3e0f143afd4b780c14d1992e67e4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page