Skip to content

Latest commit

 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LoC (Lines of Code)

A fast and simple lines-of-code analyzer for your projects.

Inspired by Onefetch and Tokei.


Requirements

  • C++17 or later
  • CMake 3.15+
  • Just (command runner)
  • nlohmann/json library (will be fetched automatically if not found)

Building

Quick Start (Recommended)

git clone <repository-url>
cd loc

nix develop
just build
just run

Using Just Commands

just build
just clean
just install

Traditional CMake

If you prefer CMake directly:

mkdir -p build
cd build
cmake ..
make
./bin/loc [directory] [options]

Usage

Basic Usage

./loc

./loc /path/of/preference

Output Formats

# Terminal output (default, colored)
./loc /path/of/preference -f terminal

./loc /path/of/preference -f json

./loc /path/of/preference -f csv

Command Line Options

loc [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

How It Works

  1. Language Detection: Detects file type based on file extension
  2. File Scanning: Recursively scans the directory for source files
  3. 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
  4. Statistics: Aggregates results by language
  5. Formatting: Outputs results in the requested format

Limitations

  • Ignores files in common directories (.git, build, node_modules, .venv)
  • Hidden files are excluded by default (use --hidden to include)
  • Comment detection is basic and may not handle all edge cases
  • Does not follow symbolic links by default

Similar Tools

  • Onefetch - Git repository summary
  • Tokei - Fast lines of code counter
  • cloc - Count lines of code

Acknowledgments

About

A fast and simple lines-of-code analyzer for your projects.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages