Skip to content

Anuar-boop/codecount

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

codecount

A zero-dependency Python source code line counter, similar to cloc and tokei. Count lines of code, comments, and blanks across 50+ programming languages.

Features

  • Count lines of code, comments, and blanks by language
  • Support for 50+ programming languages
  • Respects .gitignore patterns automatically
  • Default ignore list (node_modules, .git, pycache, etc.)
  • Directory tree view with line counts
  • Compare two directories side-by-side
  • Output as table, JSON, CSV, or Markdown
  • Sort by lines, files, language, or any column
  • Custom ignore patterns
  • Single file, zero dependencies

Requirements

  • Python 3.7+
  • No external dependencies

Installation

git clone https://github.com/Anuar-boop/codecount.git
cd codecount
chmod +x codecount.py

Usage

Count lines in current directory

python3 codecount.py .

Count lines in a specific directory

python3 codecount.py src/

JSON output

python3 codecount.py . --json

CSV output

python3 codecount.py . --csv > stats.csv

Markdown output (for READMEs)

python3 codecount.py . --markdown >> README.md

Sort by files count

python3 codecount.py . --sort files

Directory tree view

python3 codecount.py . --tree
python3 codecount.py . --tree --tree-depth 5

Compare two directories

python3 codecount.py --compare project-v1/ project-v2/

Custom ignore patterns

python3 codecount.py . -i "*.test.js" "fixtures" "mocks"

Output Example

Table (default)

  my-project
-------------------------------------------------------------------
Language              Files       Code   Comments     Blanks      Total
-------------------------------------------------------------------
TypeScript               45     12,340      1,230        890     14,460
JavaScript               12      3,210        450        320      3,980
Python                    8      2,100        380        210      2,690
CSS                       6        890        120         80      1,090
YAML                      4        230         45         30        305
Markdown                  3        180          0         60        240
JSON                      2        120          0          0        120
-------------------------------------------------------------------
Total                    80     19,070      2,225      1,590     22,885
-------------------------------------------------------------------

Directory Tree

|-- src/ (65 files, 15,340 lines)
|   |-- components/ (30 files, 8,200 lines)
|   |-- hooks/ (10 files, 2,100 lines)
|   |-- services/ (15 files, 3,800 lines)
|   --- utils/ (10 files, 1,240 lines)
|-- tests/ (12 files, 3,500 lines)
--- config/ (3 files, 230 lines)

Compare

-------------------------------------------------------------------
Language           Dir1 Code  Dir2 Code       Diff   Change
-------------------------------------------------------------------
TypeScript           10,200     12,340     +2,140  +21.0%
JavaScript            3,500      3,210       -290   -8.3%
Python                1,800      2,100       +300  +16.7%
-------------------------------------------------------------------

Supported Languages

Python, JavaScript, TypeScript, JSX, TSX, Java, C, C++, C#, Go, Rust, Ruby, PHP, Swift, Kotlin, Scala, R, Lua, Perl, Shell, Bash, Zsh, HTML, CSS, SCSS, Sass, Less, SQL, YAML, TOML, XML, JSON, Markdown, Dart, Vue, Svelte, Elixir, Erlang, Haskell, OCaml, Clojure, Nim, Zig, Terraform, Protobuf, Pine Script, Solidity, and more.

License

MIT License - see LICENSE for details.

About

Zero-dependency Python source code line counter (like cloc/tokei). Count code, comments, blanks for 50+ languages.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages