codestat-0.2.0 is not a library.
CodeStat
A fast code statistics tool written in Rust. Counts lines of code and shows language distribution for Git repositories or directories.
Features
- Fast parallel processing using Rayon
- Memory-safe Rust implementation
- Counts code, comments, and blank lines separately
- Detects 50+ programming languages
- Respects .gitignore rules
- Output in table, JSON, or CSV format
- Incremental caching for faster re-runs
Installation
Or build from source:
The binary will be at target/release/codestat.
Usage
Basic usage:
# Analyze current directory
# Analyze specific directory
# Analyze single file
Output formats:
# Table (default)
# JSON
# CSV
Options:
# Show per-file statistics
# Show progress
# Include hidden files
# Filter by language
# Exclude patterns
# Disable parallel processing (less memory)
# Follow symlinks
Example Output
Table format:
================================================================================
Language Files Lines Code Comments Blanks
--------------------------------------------------------------------------------
Rust 9 2536 1993 215 328
Markdown 2 356 260 0 96
TOML 1 35 32 0 3
--------------------------------------------------------------------------------
Total 12 2927 2285 215 427
================================================================================
Statistics completed in 0.014s (857 files/s, 209071 lines/s)
JSON format:
Implementation Notes
Techniques used for performance:
- Memory mapping: Large files use mmap to avoid copy overhead
- Byte-level parsing: Works on
&[u8]directly, no UTF-8 validation - Parallel batching: Files sorted by size for better load balancing
- Cached detection: Language detection uses static HashMap with O(1) lookup
License
MIT