A Rust CLI that summarizes codebases at blazing speed. It counts files, lines, and bytes by language; respects .gitignore and .ignore files; can follow symlinks; optionally displays per-file details; and outputs in either human-readable or machine-friendly formats.
cargo install codestatsgit clone https://github.com/trypsynth/codestats
cd codestats
cargo install --path .- Analyze the current directory and provide a human-readable report:
cs - Get a verbose, per-file detail for
src/in JSON format:cs -v src -o json - List supported languages (400+):
cs -l
Codestats can read settings from TOML while keeping full CLI compatibility. Precedence: CLI args > explicit --config path > nearest found file > built-in defaults.
Search order:
--config <path>(errors if missing)./.codestats.toml./codestats.toml~/.config/codestats/config.toml~/.codestats.toml
Example .codestats.toml:
[analysis]
verbose = false
respect_gitignore = true
include_hidden = false
follow_symlinks = false
[display]
number_style = "plain" # plain|comma|underscore|space
size_units = "binary" # binary|decimal
precision = 1 # 0-6
sort_by = "lines" # lines|code|comments|blanks|files|size|name
sort_direction = "desc" # asc|desc
output = "human" # human|json|json-compact|csv|tsv|markdown|htmlUsage: cs [OPTIONS] [PATH]
PATHThe path to analyze (directory is recursive). Defaults to the current directory.
-c, --config <PATH>Path to a TOML config file.-l, --langsList all supported languages and exit.-v, --verboseShow per-file detail instead of just the summary.-i, --no-gitignoreDo not respect.gitignorefiles.-H, --hiddenSearch hidden files and directories.-s, --symlinksFollow symlinks (use carefully to avoid cycles).-n, --number-style <plain|comma|underscore|space>Number formatting style. Default:plain.-u, --size-units <binary|decimal>Human-readable size units. Default:binary.-p, --precision <0-6>Percentage precision. Default:1.-S, --sort-by <lines|code|comments|blanks|files|size|name>Sort key for languages (and per-file detail when verbose). Default:lines.-d, --sort-dir <asc|desc>Sort direction. Default:desc.-o, --output <human|json|json-compact|csv|tsv|markdown|html>Output format. Default:human.-h, --helpPrint help.-V, --versionPrint version.
hyperfine --warmup 1 "target/release/cs /home/quin" "tokei /home/quin"
| Command | Mean ± σ | Min … Max |
|---|---|---|
cs /home/quin |
2.606 s ± 0.024 s | 2.587 s … 2.643 s |
tokei /home/quin |
9.396 s ± 0.029 s | 9.364 s … 9.442 s |
Codestats ran about 3.6 times faster than tokei on this machine (a modest Beelinks mini PC) when scanning my large home directory with caches warmed up.
Codestats is licensed under the Zlib License.