A blazing-fast, parallel Lines of Code counter with Rich terminal UI
Project description
codelines โก
"How many lines of code is this thing, anyway?"
The question that keeps tech leads up at night. The question that fuels endless Slack debates about "what counts as a line." The question that
codelinesanswers in milliseconds while your coworkers are still arguing about whether blank lines should be included.
๐ญ The Problem
You just inherited a monorepo. The README says "lightweight microservice architecture" but node_modules has 87,000 files and there's a backup-final-v2-old (copy).py somewhere. You need numbers. Cold, hard, undeniable numbers.
You try wc -l. It counts package-lock.json. It counts dist/. It doesn't know what a .gitignore is. It stares back at you with the blank expression of a tool that peaked in 1971.
Enter codelines.
โก What It Does
$ codelines .
Summary
โโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโ
โ Metric โ Value โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโค
โ Total Files (counted) โ 847 โ
โ Total Lines (real code) โ 124,532 โ
โ Workers โ 16 โ
โ Skipped Directories โ 23 โ
โ Skipped Files โ 156 โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโ
Top File Types (Actual Code)
โโโโโโโโโโโโโฌโโโโโโโโโโฌโโโโโโโโโ
โ Extension โ Lines โ % โ
โโโโโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโค
โ .py โ 52,341 โ 42.0 โ
โ .js โ 28,912 โ 23.2 โ
โ .ts โ 18,234 โ 14.6 โ
โ .css โ 12,567 โ 10.1 โ
โ .html โ 8,901 โ 7.1 โ
โโโโโโโโโโโโโดโโโโโโโโโโดโโโโโโโโโ
It's fast. Multi-threaded. Uses all your cores. Respects .gitignore. Gives you beautiful tables, JSON, or CSV. And it makes you look like you know exactly what's going on โ even when you don't.
๐ฆ Installation
pip install codelines
That's it. No system dependencies. No Docker. No "just clone and run these 47 scripts." One command. You're counting.
$ codelines --version
codelines 0.1.0
๐ Quick Start
# The basics
codelines . # Count current directory
codelines ~/projects/monorepo # Point it anywhere
# Get nerdy
codelines . --format json # Machine-readable output
codelines . --format csv # Spreadsheet-ready
codelines . --include .py .rs .go # Only the languages you care about
codelines . --exclude .json .lock # Skip the noise
codelines . --max-depth 3 # Don't go too deep, man
codelines . --sort-by ext --top 10 # Top 10 extensions, sorted
codelines . --workers 16 # Unleash the cores
codelines . --quiet # I don't need the show, just the numbers
๐ฎ Full Command Reference
Usage: codelines [OPTIONS] [DIRECTORY]
Arguments:
directory Directory to scan (default: current directory)
Options:
--format, -f [table|json|csv] Output format (default: table)
--include, -i EXT [EXT ...] Only count these extensions
--exclude, -e EXT [EXT ...] Skip these extensions
--max-depth, -d N Maximum directory depth
--workers, -w N Worker threads (default: CPU ร 2)
--ignore-file PATH Additional ignore file
--sort-by, -s [ext|dir|lines] Sort criterion (default: lines)
--top, -t N Show top N results (default: 5)
--quiet, -q Suppress progress display
--version, -V Show version and exit
--help, -h Show this message
๐ง The Philosophy
What counts as a "line"?
A line is a \n character. If your file has newlines, we count them. No opinions. No debates. No "but what about docstrings?" Just the raw, unfiltered truth your files are telling you.
What files get counted?
By default, we recognize 40+ code file extensions โ Python, JavaScript, TypeScript, Go, Rust, Java, C/C++, HTML, CSS, JSON, YAML, Markdown, Shell, SQL, and more. You can add or remove extensions with --include and --exclude.
What gets ignored?
We automatically read your .gitignore and .ignore files. Got node_modules? Skipped. .venv? Skipped. __pycache__? Skipped. We also eat our own dog food โ the scanner itself is lightning fast because it skips boring directories before even looking at files.
๐ Architecture (for the curious)
Ask for a directory
โ
โผ
โโโโโโโโโโโโโโโ
โ Scanner โ โ Walks the tree, applies .gitignore, respect depth limits
โโโโโโโโฌโโโโโโโ
โ list of Path objects
โผ
โโโโโโโโโโโโโโโ
โ Thread Pool โ โ min(32, CPUร2) workers, chunked binary reads (1 MiB)
โ Dispatcher โ
โโโโโโโโฌโโโโโโโ
โ per-file line counts
โผ
โโโโโโโโโโโโโโโ
โ Aggregator โ โ Groups by extension, directory, computes percentages
โโโโโโโโฌโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโ
โ Reporter โ โ table (Rich), JSON, or CSV โ your choice
โโโโโโโโโโโโโโโ
No temporary files. No database. No config file to manage. Just a pure pipeline from filesystem to your eyeballs.
๐ฅ Real-World Speed
| Scenario | Files | Lines | Time |
|---|---|---|---|
| Small project (codelines itself) | 11 | 1,230 | <0.1s |
| Medium monorepo | 2,500 | 180,000 | ~0.5s |
| Large repo (Hermes Agent) | 87,000 | 17,000,000 | ~3s |
Benchmarked on a 4-core VPS. Your speeds may vary โ usually faster on real hardware.
๐ค But Why?
Because wc -l doesn't know what a gitignore is. Because counting lines shouldn't require a shell pipeline that looks like a cat walked across your keyboard. Because developers deserve tools that are fast, pretty, and don't make them think about edge cases.
And honestly? Because it was fun to build.
๐ Built With
- Rich โ the terminal UI library that makes CLI apps feel like magic
- Python's
ThreadPoolExecutorโ because blocking I/O is for people with infinite patience pathlibโ because string concatenation for file paths is a crime- Pure Python โ zero native dependencies, installs anywhere
๐ License
MIT ยฉ Muneer Alam
built with excessive coffee and mild obsession with counting things
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file codelines-0.1.1.tar.gz.
File metadata
- Download URL: codelines-0.1.1.tar.gz
- Upload date:
- Size: 13.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2686269939083b2609ad99e2e2e3a55edc192d590d75f053744e6d446b696548
|
|
| MD5 |
c970ee7cea1bc08a75ee416ba2b0a8a0
|
|
| BLAKE2b-256 |
e725c9753b912b5830a3d1afba7b8194e2db8bdaf42aea185bf6ab2028fa3812
|
File details
Details for the file codelines-0.1.1-py3-none-any.whl.
File metadata
- Download URL: codelines-0.1.1-py3-none-any.whl
- Upload date:
- Size: 14.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3d6bed7c5c3fabcc2265194d49d3f91e1e5eea85b2cbcec986f042da20ea5659
|
|
| MD5 |
02621488831c44301a01b17ccf53f7b0
|
|
| BLAKE2b-256 |
c9bb1859741e41d9235069405b49bb58178ae1f603a474c949531ec63cd75d65
|