A fast and simple lines-of-code analyzer for your projects.
Inspired by Onefetch and Tokei.
- C++17 or later
- CMake 3.15+
- Just (command runner)
- nlohmann/json library (will be fetched automatically if not found)
git clone <repository-url>
cd loc
nix develop
just build
just runjust build
just clean
just installIf you prefer CMake directly:
mkdir -p build
cd build
cmake ..
make
./bin/loc [directory] [options]./loc
./loc /path/of/preference# Terminal output (default, colored)
./loc /path/of/preference -f terminal
./loc /path/of/preference -f json
./loc /path/of/preference -f csvloc [directory] [options]
Options:
-f, --format FORMAT Output format: terminal (default), json, csv
-l, --languages FILE Path to languages.json configuration
--exclude PATTERN Exclude files matching pattern
--follow-symlinks Follow symbolic links
--hidden Include hidden files
- Language Detection: Detects file type based on file extension
- File Scanning: Recursively scans the directory for source files
- Analysis: Counts:
- Total Lines: All lines in the file
- Code Lines: Non-empty, non-comment lines
- Comment Lines: Single-line and multi-line comments
- Whitespace Lines: Empty lines
- Indent Lines: Lines containing only indentation characters
- Statistics: Aggregates results by language
- Formatting: Outputs results in the requested format
- Ignores files in common directories (.git, build, node_modules, .venv)
- Hidden files are excluded by default (use
--hiddento include) - Comment detection is basic and may not handle all edge cases
- Does not follow symbolic links by default
- languages.json - Language definitions modeled on Tokei's language database