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 "cs ~" "tokei ~"
| Command | Mean ± σ | Min … Max |
|---|---|---|
cs ~ |
1.952 s ± 0.034 s | 1.915 s … 1.997 s |
tokei ~ |
7.538 s ± 0.045 s | 7.466 s … 7.609 s |
Codestats ran about 3.86 ± 0.07 times faster than tokei on this machine (a modest Beelinks mini PC) when scanning a massive home directory with caches warmed up.
Codestats is licensed under the Zlib License.