Skip to content

Latest commit

ย 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ“Š Codoco

Count every line. Know every project.

A fast, dependency-free, cross-platform source code line counter written in C.
Codoco scans your project, detects languages, classifies lines as code / comments / blanks, and produces beautiful terminal, JSON, CSV, XML, or HTML reports.

CI Release GitHub Release Build Guide License Language Platforms

Codoco HTML report preview

๐Ÿ“ธ HTML report generated from the Codoco repository itself.

๐Ÿ“– Looking for manual installation and build instructions?
See HOW-TO-BUILD-MYSELF.md

If Codoco saves you time, please consider giving it a โญ on GitHub!


๐Ÿ“š Table of Contents


๐Ÿงญ Overview

Codoco is a lightweight, high-performance code statistics tool designed to give you an instant, clear picture of any codebase.

Point it at a directory, a set of files, or a whole repository, and Codoco will:

  • ๐Ÿ”Ž Recursively scan source files
  • ๐Ÿง  Detect programming languages by extension, filename, or shebang
  • ๐Ÿงฎ Count lines, code lines, comment lines, blank lines, and bytes
  • ๐Ÿšซ Skip binary files and common build/dependency directories
  • ๐Ÿ“ฆ Produce polished reports for humans and machines

Codoco is especially useful for:

  • ๐Ÿ“ˆ Repository size analysis
  • ๐Ÿ“Š CI dashboards
  • ๐Ÿ“ Documentation generation
  • ๐Ÿ” Codebase audits
  • ๐ŸŒ Language distribution reports
  • ๐Ÿ“„ Per-file inspection
  • ๐Ÿงพ Quick statistics for pull requests or project reviews

โœจ Why Codoco?

Many line counters exist โ€” but Codoco aims to be:

โšก Fast

Written in pure C with minimal overhead, Codoco is designed for speed and low memory usage.

๐Ÿ“ฆ Dependency-Free Runtime

The final binary only needs the standard C library and POSIX-compatible system interfaces. No Python, Node.js, Ruby, or runtime dependencies are required.

๐ŸŒ Cross-Platform

Codoco supports Linux, macOS, Windows, and Termux across many CPU architectures.

๐ŸŽจ Beautiful Output

From clean terminal tables to polished HTML reports with charts, Codoco makes statistics readable and shareable.

๐Ÿง  Smart Detection

Codoco does not only look at extensions. It also understands special filenames like Makefile, Dockerfile, CMakeLists.txt, Gemfile, .gitignore, and more. It can even inspect shebang lines and apply a C/C++ header heuristic.

๐Ÿ”ง Scriptable

JSON, CSV, and XML outputs make Codoco easy to integrate into tooling, dashboards, and automation pipelines.


๐Ÿš€ Features

  • ๐ŸŒ 180+ built-in language definitions
  • ๐Ÿ–ฅ๏ธ Terminal-first design
    • Adaptive table layout based on terminal width
    • Unicode box drawing with ASCII fallback
    • Optional color output
  • ๐Ÿ“ค Multiple output formats
    • Table
    • JSON
    • CSV
    • XML
    • HTML
  • ๐ŸŒ HTML reports
    • Dark and light themes
    • Responsive layout
    • Donut chart for language distribution
    • Print-friendly styling
  • ๐Ÿ“„ Per-file reporting
  • ๐Ÿ”€ Sorting and limiting
    • Sort by name, files, lines, code, comments, blanks, or bytes
    • Ascending/descending order
    • Top-N results
  • ๐ŸŽฏ Powerful filtering
    • Include/exclude languages
    • Include/exclude extensions
    • Exclude directories with glob patterns
    • Minimum/maximum file size filters
  • ๐Ÿงน Smart scanning behavior
    • Binary file detection
    • Default ignore list for common build and dependency directories
    • Hidden file control
    • Symlink traversal control
    • Depth-limited recursion
  • ๐Ÿ“ฅ Robust installer
    • One-line install for Unix-like systems
    • PowerShell installer for Windows
    • Checksum verification support

โšก Quick Start

Count the current directory

codoco .

Show only the top 10 languages by code lines

codoco --sort=code --top=10 .

Generate HTML reports

codoco --html -o report.html .

This produces theme-specific HTML files such as:

report-dark.html
report-light.html

Export JSON

codoco --json . > codoco.json

Per-file report sorted by bytes

codoco --by-file --sort=bytes --order=desc .

Scan only selected languages

codoco --include-lang="C,C++,Python,Shell" .

Exclude directories

codoco --exclude-dir="vendor,third_party,docs" .

๐Ÿ“ฅ Installation

Codoco provides simple installers for Unix-like systems and Windows.

For manual installation, release extraction, building from source, Make usage, and troubleshooting, see:

๐Ÿ‘‰ HOW-TO-BUILD-MYSELF.md


๐Ÿง Linux / ๐ŸŽ macOS / ๐Ÿ“ฑ Termux

Install the latest release:

curl -fsSL https://raw.githubusercontent.com/RaptorVampire/Codoco/main/install.sh | sh

The installer will:

  1. ๐Ÿงญ Detect your OS and architecture
  2. โฌ‡๏ธ Download the correct release artifact
  3. โœ… Verify checksum when available
  4. ๐Ÿ“‚ Install the binary into $HOME/.local/bin by default
  5. ๐Ÿ›ค๏ธ Update your shell PATH if possible

Installer environment variables

Variable Default Description
VERSION latest Install a specific tag, e.g. v1.0.0
PREFIX $HOME/.local Installation prefix
BINDIR $PREFIX/bin Binary destination directory
YES=1 disabled Skip confirmation prompt
FORCE=1 disabled Reinstall even if already installed
UNINSTALL=1 disabled Remove Codoco
NO_PATH=1 disabled Do not modify shell rc files
NO_VERIFY=1 disabled Skip checksum verification

Examples

Install a specific version:

curl -fsSL https://raw.githubusercontent.com/RaptorVampire/Codoco/main/install.sh | VERSION=v1.0.0 sh

Install system-wide:

curl -fsSL https://raw.githubusercontent.com/RaptorVampire/Codoco/main/install.sh | sudo PREFIX=/usr/local BINDIR=/usr/local/bin sh

Assume yes and skip PATH modification:

curl -fsSL https://raw.githubusercontent.com/RaptorVampire/Codoco/main/install.sh | YES=1 NO_PATH=1 sh

Uninstall:

curl -fsSL https://raw.githubusercontent.com/RaptorVampire/Codoco/main/install.sh | UNINSTALL=1 sh

๐ŸชŸ Windows PowerShell

Install the latest release:

irm https://raw.githubusercontent.com/RaptorVampire/Codoco/main/install.ps1 | iex

By default, Codoco is installed to:

%LOCALAPPDATA%\Programs\Codoco

and added to your user PATH.

PowerShell installer options

Option Description
-Version Install a specific release tag
-InstallDir Installation directory
-Uninstall Remove Codoco
-NoPath Do not modify PATH
-Force Reinstall even if already installed
-NoVerify Skip checksum verification

Open a new terminal after installation so PATH changes take effect.


๐Ÿ› ๏ธ Building From Source

If you want to compile Codoco yourself, install it manually, use Make targets, build packages, or debug build problems, read the full guide here:

๐Ÿ‘‰ HOW-TO-BUILD-MYSELF.md

That guide includes:

  • ๐Ÿงฑ Building with make
  • ๐Ÿงฐ Direct compilation without Make
  • ๐Ÿ“ฅ Manual release installation
  • ๐Ÿ“ฆ Local .deb / .rpm packaging
  • ๐Ÿงช Smoke tests
  • ๐Ÿฉน Troubleshooting

๐Ÿงช Usage Examples

Basic scan

codoco .

Scan multiple paths

codoco src include tests

Show top 15 languages by total lines

codoco --top=15 .

Sort by number of files

codoco --sort=files --order=desc .

Show per-file statistics

codoco --by-file .

Largest files by bytes

codoco --by-file --sort=bytes --top=25 .

Count only C, C++, and Python

codoco --include-lang="C,C++,Python" .

Exclude Markdown and JSON

codoco --exclude-lang="Markdown,JSON" .

Include only selected extensions

codoco --include-ext="c,h,cpp,hpp" .

Exclude directories with glob patterns

codoco --exclude-dir="build,*cache*,third_party" .

Include hidden files

codoco --hidden .

Limit recursion depth

codoco --depth=2 .

Disable recursion

codoco --no-recursive .

Follow symbolic links

codoco --follow .

Force every file to be treated as Python

codoco --force-lang=Python .

ASCII-only terminal output

Useful for legacy terminals or CI logs:

codoco --ascii --no-color .

Force color output

codoco --color .

Hide bars and percentages

codoco --no-bar --no-percent .

Quiet mode

codoco --quiet .

๐Ÿ“ค Output Formats

Codoco supports five output formats.

Format Best For
table Human-readable terminal output
json APIs, dashboards, tooling
csv Spreadsheets and data analysis
xml Legacy integrations and structured reports
html Shareable visual reports

๐Ÿ–ฅ๏ธ Terminal Table

The default output is an adaptive terminal table.

It includes:

  • ๐Ÿท๏ธ Project banner
  • ๐Ÿ“ˆ Scan statistics
  • ๐Ÿ“‹ Language table
  • โž• Total summary
  • ๐Ÿ“Š Optional language distribution bars
  • ๐Ÿ“„ Optional per-file report

The terminal renderer is width-aware:

  • It avoids wrapping
  • It truncates long values safely
  • It falls back to ASCII when requested
  • It supports Unicode box drawing when available

Example:

codoco .

๐Ÿงพ JSON

Generate structured JSON output:

codoco --json .

Example structure:

{
  "tool": "Codoco",
  "version": "1.0.0",
  "url": "https://github.com/RaptorVampire/Codoco",
  "license": "Apache-2.0 OR MIT",
  "summary": {
    "files": 123,
    "lines": 45678,
    "code": 34567,
    "comments": 6789,
    "blanks": 4321,
    "bytes": 1234567
  },
  "languages": [
    {
      "name": "C",
      "files": 40,
      "lines": 20000,
      "code": 15000,
      "comments": 3000,
      "blanks": 2000,
      "bytes": 700000
    }
  ]
}

With --by-file, a files array is also included:

codoco --json --by-file .

๐Ÿ“Š CSV

Generate CSV output:

codoco --csv .

Default columns:

Language,Files,Lines,Code,Comments,Blanks,Bytes,Percent

With --by-file, an additional per-file section is emitted:

Path,Language,Lines,Code,Comments,Blanks,Bytes

๐Ÿ“ฐ XML

Generate XML output:

codoco --xml .

Example:

<?xml version="1.0" encoding="UTF-8"?>
<codoco tool="Codoco" version="1.0.0" url="https://github.com/RaptorVampire/Codoco" license="Apache-2.0 OR MIT">
  <summary files="123" lines="45678" code="34567" comments="6789" blanks="4321" bytes="1234567"/>
  <languages>
    <language name="C" files="40" lines="20000" code="15000" comments="3000" blanks="2000" bytes="700000" percent="43.79"/>
  </languages>
</codoco>

๐ŸŒ HTML Report

Codoco can generate a polished standalone HTML report.

codoco --html .

By default, both dark and light themes are generated:

codoco-report-dark.html
codoco-report-light.html

Specify a base output name:

codoco --html -o report.html .

This produces:

report-dark.html
report-light.html

Choose a theme:

codoco --html --theme=dark .
codoco --html --theme=light .
codoco --html --theme=both .

HTML report features

  • ๐ŸŽจ Modern dashboard-like layout
  • ๐Ÿงฎ Summary cards for files, lines, code, comments, blanks, and size
  • ๐Ÿฉ SVG donut chart for language share
  • ๐Ÿ“Œ Legend with percentages
  • ๐Ÿ“‹ Full language table
  • ๐ŸŒ— Dark and light themes
  • ๐Ÿ“ฑ Responsive mobile layout
  • ๐Ÿ–จ๏ธ Print-friendly CSS

This makes Codoco especially useful for:

  • ๐Ÿ“– Project documentation
  • ๐Ÿ“Š Internal dashboards
  • ๐Ÿ” Code review summaries
  • ๐ŸŒ Open-source repository reports
  • ๐Ÿ“ค Shareable statistics without installing additional tools

โŒจ๏ธ Command-Line Reference

General

Usage: codoco [OPTIONS] [PATH...]

If no path is given, Codoco scans the current directory.


Output options

Option Description
--format=FMT Output format: table, json, csv, xml, html
--json Shortcut for --format=json
--csv Shortcut for --format=csv
--xml Shortcut for --format=xml
--html Shortcut for --format=html
-o, --output=FILE Base output path for HTML reports
--theme=MODE HTML theme: dark, light, both
--by-file Include per-file report
--no-bar Hide bar charts in terminal output
--no-percent Hide percentages
--no-total Hide total row
--no-header Hide table headers
--ascii ASCII-only output
--no-color Disable ANSI colors
--color Force ANSI colors
--top=N Show only top N entries
-q, --quiet Suppress non-essential messages

Sorting options

Option Description
--sort=KEY Sort key: name, files, lines, code, comments, blanks, bytes
--order=ORD Sort order: asc or desc

Default:

--sort=lines --order=desc

Filtering options

Option Description
--include-lang=L Only include languages in comma-separated list
--exclude-lang=L Exclude languages in comma-separated list
--include-ext=L Only include extensions in comma-separated list
--exclude-ext=L Exclude extensions in comma-separated list
--exclude-dir=L Exclude directory names using comma-separated globs
--max-file-size=N Skip files larger than N bytes
--min-file-size=N Skip files smaller than N bytes
--force-lang=LANG Treat every scanned file as the given language

Traversal options

Option Description
-r, --recursive Recursive scan, enabled by default
--no-recursive Disable recursion
-d, --depth=N Maximum recursion depth
--hidden Include hidden files and directories
--follow Follow symbolic links

Information options

Option Description
-h, -?, -help, --help Show help
-v, --version Show version
--license Show license information
--list-langs, --langs List supported languages

๐Ÿง  Language Detection

Codoco uses a layered detection strategy.

Detection order

  1. ๐ŸŽฏ Forced language

    • If --force-lang is used, Codoco applies it.
  2. ๐Ÿ“› Filename rules

    • Special files are recognized by name.
    • Examples:
      • Makefile
      • Dockerfile
      • CMakeLists.txt
      • Gemfile
      • Rakefile
      • package.json
      • Cargo.toml
      • go.mod
      • .gitignore
      • .editorconfig
      • Vagrantfile
      • Jenkinsfile
  3. ๐Ÿงฉ File extension

    • Most languages are detected by extension.
    • Extension matching is case-insensitive.
  4. ๐Ÿงช C/C++ header heuristic

    • .h files are treated as C by default.
    • If a sibling C++ source file exists, Codoco reclassifies the header as C++.
  5. ๐Ÿ‘ Shebang detection

    • If no language is found, Codoco checks the first line for a shebang.
    • Examples:
      • #!/usr/bin/env python3
      • #!/bin/bash
      • #!/usr/bin/env node
  6. ๐Ÿ“„ Fallback

    • Text-like files without a recognized language are treated as Text.

๐Ÿ—ฃ๏ธ Supported Languages

Codoco ships with 180+ built-in language definitions.

You can always list them locally with:

codoco --list-langs

Broad language coverage includes

๐Ÿงฑ Systems languages

  • C
  • C++
  • Rust
  • Zig
  • D
  • Ada
  • Pascal
  • Fortran
  • Assembly

๐Ÿงฐ Application languages

  • Python
  • Ruby
  • JavaScript
  • TypeScript
  • Java
  • Kotlin
  • Scala
  • C#
  • Go
  • PHP
  • Dart
  • Lua
  • Perl
  • Raku

๐ŸŒ Web and markup

  • HTML
  • CSS
  • SCSS
  • SASS
  • LESS
  • Markdown
  • reStructuredText
  • AsciiDoc
  • XML
  • JSON
  • YAML
  • TOML

๐Ÿš Shell and scripting

  • Shell
  • Bash
  • Zsh
  • Fish
  • PowerShell
  • Batch
  • VBScript
  • AWK
  • Sed
  • Tcl

๐Ÿ“ˆ Data and science

  • R
  • MATLAB
  • Octave
  • Julia
  • Wolfram
  • SAS
  • Stata
  • SPSS

โš™๏ธ Configuration and infrastructure

  • Dockerfile
  • Makefile
  • CMake
  • Meson
  • Bazel
  • Gradle
  • Terraform
  • HCL
  • Nix
  • Puppet
  • INI
  • TOML
  • YAML

๐Ÿงฎ Hardware and embedded

  • Verilog
  • SystemVerilog
  • VHDL
  • CUDA
  • OpenCL
  • GLSL
  • HLSL

๐Ÿงฌ Other special formats

  • SQL
  • GraphQL
  • Protocol Buffers
  • Thrift
  • LLVM IR
  • WebAssembly
  • COBOL
  • Lisp
  • Haskell
  • OCaml
  • Erlang
  • Elixir
  • Prolog

The authoritative list is always available via:

codoco --list-langs

๐Ÿ—‚๏ธ File Filtering and Traversal

Codoco is designed to avoid noise.

Default ignored directories

By default, Codoco skips common generated and dependency directories such as:

  • .git
  • .hg
  • .svn
  • node_modules
  • vendor
  • __pycache__
  • .pytest_cache
  • .mypy_cache
  • .venv
  • venv
  • target
  • build
  • dist
  • out
  • bin
  • obj
  • .idea
  • .vscode
  • .gradle
  • .cargo
  • DerivedData
  • .next
  • .nuxt
  • coverage

Binary files

Codoco automatically skips many binary file types, including:

  • ๐Ÿงฑ Executables and object files
  • ๐Ÿ—œ๏ธ Archives
  • ๐Ÿ–ผ๏ธ Images
  • ๐ŸŽต Audio/video
  • ๐Ÿ”ค Fonts
  • ๐Ÿ“š Documents
  • ๐Ÿ—ƒ๏ธ Databases
  • ๐Ÿ“ฆ Compiled artifacts

Additional binary detection is performed by scanning file contents for NUL bytes.

Hidden files

Hidden files and directories are excluded by default.

Include them with:

codoco --hidden .

Symlinks

Symlinks are not followed by default.

Follow them with:

codoco --follow .

๐Ÿ”ข How Counting Works

Codoco uses a lightweight line classification engine.

Each line is classified as one of:

  • ๐Ÿ’ป Code
  • ๐Ÿ’ฌ Comment
  • โฌœ Blank

Counting rules

  • A line containing only whitespace is counted as blank.
  • A line containing code is counted as code, even if it also contains a trailing comment.
  • A line containing only comment syntax is counted as comment.
  • Block comments are recognized where supported by the language definition.
  • String literals and escapes are considered during classification.
  • Language-specific line comment markers are respected.
  • Block comment start/end markers are respected.

Example

For C-like code:

int main(void) {
    // start program
    return 0;
}

Typical classification:

int main(void) {   -> code
// start program   -> comment
return 0;          -> code
}                  -> code

Important note

Codoco is not a full compiler or parser.
It uses fast, practical heuristics that are well suited for project statistics, trend reporting, and repository analysis.


๐Ÿ–ฅ๏ธ Supported Platforms

Codoco targets a wide range of operating systems and architectures.

Official release targets

๐Ÿง Linux

  • linux-x86_64
  • linux-i686
  • linux-aarch64
  • linux-armv7
  • linux-riscv64
  • linux-x86_64-static

๐ŸŽ macOS

  • macos-x86_64
  • macos-arm64

๐ŸชŸ Windows

  • windows-x86_64
  • windows-i686

Additional environments

Codoco also works in:

  • ๐Ÿ“ฑ Termux on Android
  • ๐Ÿงฐ MSYS2 / MinGW environments
  • ๐Ÿ“ฆ Containers and minimal Linux systems

๐Ÿ“ Project Layout

Codoco/
โ”œโ”€โ”€ include/            # Public headers
โ”‚   โ”œโ”€โ”€ codoco.h
โ”‚   โ”œโ”€โ”€ languages.h
โ”‚   โ”œโ”€โ”€ options.h
โ”‚   โ”œโ”€โ”€ printer.h
โ”‚   โ”œโ”€โ”€ scanner.h
โ”‚   โ”œโ”€โ”€ stats.h
โ”‚   โ”œโ”€โ”€ utils.h
โ”‚   โ””โ”€โ”€ version.h
โ”œโ”€โ”€ src/                # Implementation
โ”‚   โ”œโ”€โ”€ languages.c
โ”‚   โ”œโ”€โ”€ main.c
โ”‚   โ”œโ”€โ”€ options.c
โ”‚   โ”œโ”€โ”€ printer.c
โ”‚   โ”œโ”€โ”€ scanner.c
โ”‚   โ”œโ”€โ”€ stats.c
โ”‚   โ””โ”€โ”€ utils.c
โ”œโ”€โ”€ install.sh          # Unix installer
โ”œโ”€โ”€ install.ps1         # Windows installer
โ”œโ”€โ”€ Makefile
โ”œโ”€โ”€ Screenshot.png      # HTML report preview shown above
โ”œโ”€โ”€ HOW-TO-BUILD-MYSELF.md
โ”œโ”€โ”€ LICENSE-APACHE
โ””โ”€โ”€ LICENSE-MIT

๐Ÿค Contributing

Contributions are very welcome!

You can help by:

  • ๐Ÿž Reporting bugs
  • ๐Ÿ’ก Suggesting features
  • ๐Ÿ“ Improving documentation
  • ๐ŸŒ Adding language definitions
  • ๐Ÿ”ง Fixing edge cases in counting logic
  • ๐Ÿ“ฆ Improving installers and packaging

Before submitting a pull request, please read the build guide if your change affects compilation or packaging:

๐Ÿ‘‰ HOW-TO-BUILD-MYSELF.md

Suggested checks before submitting a PR

make clean
make CFLAGS+="-Werror"
./codoco --no-color --ascii .

If you add or modify counting behavior, please include practical examples of before/after behavior in your pull request.


๐Ÿ“œ License

Codoco is dual-licensed.

You may use it under either:

  1. Apache License, Version 2.0
  2. MIT License

SPDX identifier:

Apache-2.0 OR MIT

Full license texts are provided in:

  • LICENSE-APACHE
  • LICENSE-MIT

โญ Star / Support

If Codoco helps you understand your projects faster, please consider starring the repository.

Your star helps the project grow, motivates continued development, and helps others discover Codoco.

If you find Codoco useful, please โญ the repo!

https://github.com/RaptorVampire/Codoco

About

Count every line. Know every project. Fast, portable code counter with beautiful HTML reports.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages