Skip to content

kritebh/codemeter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

CodeMeter πŸ“Š

A powerful and user-friendly CLI tool for analyzing code statistics. Count lines of code, files, and get detailed breakdowns by programming language.

CodeMeter

Features ✨

  • πŸ“ˆ Detailed Statistics: Count lines of code and files by language
  • 🎨 Beautiful Output: Colorized tables with percentages and formatting
  • πŸš€ Fast & Efficient: Optimized for large codebases
  • πŸ“Š Progress Indicators: Visual progress bar for long-running scans
  • πŸ” Smart Filtering: Automatic support for .gitignore and .codemeterignore
  • πŸ“ Multiple Formats: Output as table or JSON
  • πŸ’Ύ Export Results: Save output to files
  • 🌈 Language Detection: Recognizes 50+ programming languages

Installation

npm install -g codemeter

Usage

Basic Usage

Analyze the current directory:

codemeter

Or specify a directory:

codemeter src

Skip Directories

Skip specific directories using the --skip-dir option:

codemeter . --skip-dir node_modules .git dist

Skip File Extensions

Skip files by their extension using the --skip-ext option:

codemeter . --skip-ext log txt md

You can combine with directory skipping:

codemeter . --skip-dir node_modules --skip-ext log txt

Show Progress

For large projects, use the progress bar:

codemeter . --progress

Output Formats

Table format (default):

codemeter . --format table

JSON format:

codemeter . --format json

Save to File

Save results to a file:

codemeter . --output report.txt
codemeter . --format json --output report.json

Ignore .gitignore

By default, CodeMeter respects .gitignore files. To disable this:

codemeter . --no-gitignore

Verbose Mode

Show detailed information about the analysis:

codemeter . --verbose

Options

Option Short Description
--skip-dir <dirs...> -s Directories to skip (space-separated)
--skip-ext <exts...> -e File extensions to skip (space-separated, e.g., --skip-ext log txt)
--progress -p Show progress bar while scanning
--format <format> -f Output format: table (default) or json
--output <file> -o Save output to a file
--no-gitignore Don't use .gitignore and .codemeterignore files
--verbose Show verbose output
--version -v Display version number
--help -h Display help information

Ignore Files

.gitignore Support

CodeMeter automatically respects .gitignore files in your project. Files and directories listed in .gitignore will be excluded from analysis.

.codemeterignore

Create a .codemeterignore file in your project root to specify additional files or patterns to exclude. This file uses the same syntax as .gitignore.

Example .codemeterignore:

# Exclude test files
**/*.test.js
**/*.spec.js

# Exclude generated files
**/generated/
**/*.min.js

# Exclude documentation
docs/
*.md

Output Examples

Table Output

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Language                β”‚ Files    β”‚ Lines         β”‚ %      β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ JavaScript (.js)        β”‚ 45       β”‚ 12,345        β”‚ 45.2%  β”‚
β”‚ TypeScript (.ts)        β”‚ 23       β”‚ 8,901         β”‚ 32.6%  β”‚
β”‚ CSS (.css)              β”‚ 12       β”‚ 2,456         β”‚ 9.0%   β”‚
β”‚ HTML (.html)            β”‚ 8        β”‚ 1,234         β”‚ 4.5%   β”‚
β”‚ JSON (.json)            β”‚ 15       β”‚ 2,345         β”‚ 8.6%   β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ TOTAL                   β”‚ 103      β”‚ 27,281        β”‚ 100.0% β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”˜

JSON Output

{
  "languages": [
    {
      "extension": "js",
      "language": "JavaScript",
      "files": 45,
      "lines": 12345,
      "percentage": "45.23"
    },
    ...
  ],
  "totals": {
    "files": 103,
    "lines": 27281
  }
}

Supported Languages

CodeMeter recognizes 50+ programming languages including:

  • JavaScript/TypeScript (JS, TS, JSX, TSX)
  • Python, Java, C/C++, C#, Go, Rust
  • PHP, Ruby, Swift, Kotlin
  • HTML, CSS, SCSS, Sass, Less
  • Shell scripts (Bash, Zsh, Fish)
  • Configuration files (JSON, YAML, XML, TOML)
  • And many more...

Examples

Analyze a React Project

codemeter . --skip-dir node_modules .next --progress

Generate JSON Report

codemeter . --format json --output code-stats.json

Analyze with Custom Ignores

codemeter . --skip-dir node_modules dist build --no-gitignore

Skip Specific File Types

codemeter . --skip-ext log txt md json

Quick Analysis

codemeter src --verbose

Tips πŸ’‘

  1. Use progress bar for large projects: Add --progress when analyzing large codebases
  2. Create .codemeterignore: Use it to exclude test files, generated code, or documentation
  3. JSON format for automation: Use --format json for programmatic access to results
  4. Combine options: Mix and match options for your specific needs

Requirements

  • Node.js >= 16

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT

Author

Kritebh Lagan Bibhakar

About

A CLI tool to analyze number of files and lines of code

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors