A blazingly fast lines of code counter with a beautiful TUI, written in Go and distributed via npm.
- 🚀 Fast Analysis: Concurrent processing with worker pools
- 🎨 Beautiful TUI: Interactive terminal UI built with Charm's Bubbletea
- 📊 Detailed Statistics: Per-file, per-language, and per-author breakdowns
- 🌐 Remote Repositories: Analyze GitHub repos directly
- 🔍 20+ Languages: Accurate language detection and comment parsing
- 📦 Easy Installation: Install via npm, run via
npx - 🎯 Multiple Output Modes: Interactive TUI or static table/JSON output
# Run directly with npx
npx codeloc
# Or install globally
npm install -g codeloc
# Analyze current directory
codeloc
# Analyze a specific path
codeloc ./src
# Analyze a remote repository
codeloc https://github.com/stripsior/loc.api
codeloc stripsior/loc.api # Short format
# Enable author tracking (git blame)
codeloc --authors
# Use static output mode
codeloc --static
# JSON output for scripting
codeloc --static --output jsonFlags:
--authors Enable git blame author tracking
--static Use static output instead of interactive TUI
--branch <name> Specify branch for remote repos (default: main/master)
--output <format> Output format: table, json (requires --static)
-h, --help Help for codeloc
-v, --version Version information
- Tab / → / L: Next view
- Shift+Tab / ← / H: Previous view
- ↑ / ↓: Scroll through tables
- 1-4: Jump to specific view
- Q / Ctrl+C: Quit
- Summary: Overview of total statistics
- Languages: Breakdown by programming language
- Files: Per-file statistics sorted by size
- Authors: Contributor statistics (with
--authorsflag)
Go, JavaScript, TypeScript, Python, Java, C, C++, C#, Rust, Swift, Kotlin, Ruby, PHP, Shell, Bash, HTML, CSS, SQL, Lua, R, YAML, TOML, Dockerfile, and more.
This is a monorepo containing:
- cli/: Go CLI application
- npm/: NPM package wrapper
# Build the Go CLI
cd cli
make build
# Run locally
make run
# Build for all platforms
make build-allloc.cli/
├── cli/ # Go application
│ ├── cmd/codeloc/ # Main entry point
│ ├── internal/
│ │ ├── analyzer/ # Core analysis logic
│ │ ├── repository/ # Local/remote repo handling
│ │ ├── models/ # Data structures
│ │ └── ui/ # TUI and static output
│ └── Makefile
└── npm/ # NPM wrapper
├── bin/codeloc.js # Wrapper script
└── scripts/ # Postinstall binary downloader
This project uses GitHub Actions for automated publishing. The workflow handles version bumping, building, and releasing.
- NPM Token: Create an automation token at npmjs.com
- GitHub Secret: Add
NPM_TOKENto repository secrets - Permissions: Enable "Read and write permissions" in Actions settings
- Go to Actions tab → Publish CodeLoc
- Click Run workflow
- Select bump type:
patch- Bug fixes (1.0.0 → 1.0.1)minor- New features (1.0.0 → 1.1.0)major- Breaking changes (1.0.0 → 2.0.0)
- Click Run workflow
The workflow will:
- ✅ Bump version in
package.jsonandmain.go - ✅ Commit and tag the release
- ✅ Build binaries for all platforms
- ✅ Create GitHub release
- ✅ Publish to NPM
# Check NPM
npm view codeloc version
# Test installation
npx codeloc@latest .MIT
stripsior