| Crates.io | codestats |
| lib.rs | codestats |
| version | 0.6.0 |
| created_at | 2025-04-08 16:41:42.278684+00 |
| updated_at | 2026-01-21 00:14:05.320279+00 |
| description | A CLI tool for analyzing code statistics across different programming languages |
| homepage | |
| repository | https://github.com/trypsynth/codestats |
| max_upload_size | |
| id | 1625707 |
| size | 244,322 |
A small CLI tool that summarizes codebases at blazing speed. Built for quick audits, comparisons, scripts, or randomly being curious how much source code is in your home directory.
.gitignore and .ignore when you want it tocargo install codestats
git clone https://github.com/trypsynth/codestats
cd codestats
cargo install --path .
cssrc/ in JSON: cs -v src -o jsoncs langscs completions <shell>.gitignore rules: cs -ics -SHcs -L rustcs -e 'test_*' -e '*.md'cs --exclude-lang markdown --exclude-lang tomlcs --fail-on-errorhuman (default) for terminalsjson or json-compact for scriptscsv or tsv for spreadsheetsmarkdown or html for docs and dashboardsUsage: cs [OPTIONS] [PATH] (defaults to the current directory)
-v, --verbose Show per-file detail instead of just the summary-i, --no-gitignore Do not respect .gitignore-H, --hidden Search hidden files and directories-S, --symlinks Follow symlinks (avoid cycles)-e, --exclude <PATTERN> Exclude files or directories matching glob patterns (can be specified multiple times)-L, --lang <LANGUAGE> Only analyze files of the specified language(s) (can be specified multiple times, cannot be used with --exclude-lang)--exclude-lang <LANGUAGE> Exclude files of the specified language(s) (can be specified multiple times, cannot be used with --lang)-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. 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--fail-on-error Exit with a non-zero status code if any files are skipped due to errors-c, --config <PATH> Use a TOML config file-h, --help Print help-V, --version Print versionlangs List all supported languagescompletions <shell> Generate shell completions (e.g. bash, zsh, fish)Codestats can read settings from TOML while keeping full CLI compatibility. Search order:
--config <path> (errors if missing)./.codestats.toml./codestats.toml~/.config/codestats/config.toml~/.codestats.toml[analysis]
verbose = true
respect_gitignore = true
include_hidden = true
follow_symlinks = false
exclude_patterns = ["*.tmp", "test_*", "node_modules/*"]
include_languages = ["rust", "python"] # Only analyze these languages
# exclude_languages = ["markdown", "toml"] # Or exclude these (cannot use both)
fail_on_error = false
[display]
number_style = "comma"
size_units = "decimal"
precision = 4
sort_by = "files"
sort_direction = "desc"
output = "human"
For performance, Codestats uses memory-mapped I/O for files >=256KB. This provides significant speedups but requires that files remain stable during analysis.
Codestats uses parallel processing to maximize performance. Each worker thread maintains its own statistics which are merged at the end, minimizing lock contention. The tool is safe for concurrent execution on different directories, but should not analyze the same directory simultaneously from multiple processes.
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 3.86 ± 0.07 times faster than tokei on a small Beelinks mini PC over a massive home directory.
Codestats is licensed under the MIT License.