Version: 1.0.0
Author: Morten Johansen (mojoaar@atomicmail.io)
License: MIT
A cross-platform command-line tool to recursively count lines of code in a directory or a single file.
- Recursive directory traversal
- Single file line counting
- Exclude specific file types (defaults to excluding
.mdfiles) - JSON output support
- Cross-platform (Windows, Linux, macOS)
- Automatic binary file detection
- Detailed breakdown by file type
- Optional file path listing with
-dirsflag
go build -o cclUse the provided build script:
PowerShell (Windows):
./build.ps1Bash (Linux/macOS):
./build.shThis will create binaries for all platforms in the bin/ directory:
ccl-windows-amd64.exe(Windows)ccl-linux-amd64(Linux)ccl-darwin-amd64(macOS Intel)ccl-darwin-arm64(macOS Apple Silicon)
Or build manually for specific platforms:
Windows:
GOOS=windows GOARCH=amd64 go build -o ccl.exeLinux:
GOOS=linux GOARCH=amd64 go build -o cclmacOS (Intel):
GOOS=darwin GOARCH=amd64 go build -o cclmacOS (Apple Silicon):
GOOS=darwin GOARCH=arm64 go build -o cclCount lines in current directory (excludes .md files by default):
cclCount lines in a specific directory:
ccl /path/to/directory
# or
ccl -dir /path/to/directoryCount lines in a single file:
ccl -file /path/to/file.txtShow version information:
ccl -version-
-dir <path>- Directory to scan for code files (default: current directory)ccl -dir /path/to/directory
-
-file <path>- Count lines in a specific fileccl -file main.go
-
-exclude <extensions>- Comma-separated list of file extensions to exclude (default:.md)ccl -exclude .md,.txt,.log
-
-dirs- Include individual file paths in the outputccl -dirs
-
-json- Output results in JSON formatccl -json
-
-version- Show version informationccl -version
Count all files including markdown:
ccl -exclude ""Exclude multiple file types:
ccl -exclude .md,.txt,.json,.xmlGet JSON output for a specific directory:
ccl -json -dir /path/to/projectShow individual file paths:
ccl -dirsShow file paths with JSON output:
ccl -dirs -jsonCount lines in a single file (JSON):
ccl -file main.go -jsonDirectory: X:/golang/ccl
Total files: 42
Total lines: 3521
Breakdown by file type:
.go 15 files, 2103 lines
.js 12 files, 892 lines
.json 5 files, 215 lines
.txt 10 files, 311 lines
Directory: X:/golang/ccl
Total files: 6
Total lines: 352
Breakdown by file type:
.go 1 files, 245 lines
.gitignore 1 files, 28 lines
(no extension) 1 files, 21 lines
Files:
X:/golang/ccl/.gitignore 28 lines
X:/golang/ccl/LICENSE 21 lines
X:/golang/ccl/main.go 245 lines
{
"total_lines": 3521,
"total_files": 42,
"files_by_type": {
".go": 15,
".js": 12,
".json": 5,
".txt": 10
},
"lines_by_type": {
".go": 2103,
".js": 892,
".json": 215,
".txt": 311
},
"directory": "X:/golang/ccl"
}{
"total_lines": 352,
"total_files": 6,
"files_by_type": {
".go": 1,
".gitignore": 1
},
"lines_by_type": {
".go": 245,
".gitignore": 28
},
"directory": "X:/golang/ccl",
"files": [
{
"path": "X:/golang/ccl/.gitignore",
"lines": 28
},
{
"path": "X:/golang/ccl/main.go",
"lines": 245
}
]
}File: X:/golang/ccl/main.go
Lines: 299
{
"file": "X:/golang/ccl/main.go",
"lines": 299
}- Binary files are automatically detected and skipped (no warnings shown)
- File paths in JSON output use forward slashes (
/) for better cross-platform compatibility - The
-excludeflag is ignored when using-filemode - Empty extension means files with no extension
MIT License
Copyright (c) 2025 Morten Johansen (mojoaar@atomicmail.io)
See LICENSE file for full license text.