Universal Language Counter - Fast line counting for 119+ programming languages
Project description
Universal Language Counter (ULC)
A fast, comprehensive programming language line counter supporting 119+ languages with intelligent conflict resolution and git integration.
Features
- 119+ Programming Languages: From modern languages (Python, JavaScript, Rust) to legacy (COBOL, FORTRAN) and domain-specific (VHDL, MATLAB)
- Smart Language Detection: Content analysis for ambiguous extensions (
.h,.m,.r,.pl) - Git Integration: Auto-detects git repositories and respects
.gitignorepatterns - Custom Ignore Files: Support for
.ulcignoreto exclude files/directories from counting - Cross-Platform: Works on Windows, macOS, and Linux
- Colored Output: Professional terminal output with color coding
- Debug Mode: Unknown file analysis and extension reporting
- Security-First: Input validation and safe file handling
Quick Start
# Count current directory
python3 ulc.py
# Count specific project with git integration
python3 ulc.py /path/to/project
# Debug mode to see unknown files
python3 ulc.py . --debug
# Sort by file count, no colors
python3 ulc.py . --sort files --no-color
Installation
ULC is a single-file standalone tool - no installation required!
# Download and run immediately
wget https://raw.githubusercontent.com/your-org/ulc/main/ulc.py
python3 ulc.py /path/to/analyze
Optional Enhancements
# Better encoding detection (recommended)
pip install chardet
# 400+ language support (requires Ruby)
gem install github-linguist
python3 ulc.py --comprehensive
See INSTALL.md for detailed installation options.
Usage
usage: ulc.py [-h] [--git] [--no-git] [--depth N] [--sort {lines,files,name}]
[--verbose] [--comprehensive] [--linguist-path PATH]
[--no-color] [--debug] [--version]
[directory]
Universal Language Counter - Count lines of code across 119+ programming languages
positional arguments:
directory Directory to analyze (default: current directory)
options:
-h, --help show this help message and exit
--git Force respect .gitignore patterns (auto-detected in git repos)
--no-git Disable git integration (ignore .gitignore even in git repos)
--depth N Maximum directory depth to traverse
--sort {lines,files,name}
Sort results by lines (default), files, or name
--verbose, -v Verbose output showing each file processed
--comprehensive Use comprehensive mode with GitHub Linguist (400+ languages)
--linguist-path PATH Path to github-linguist executable
--no-color Disable colored output
--debug Enable debug mode (show unknown files and extension analysis)
--version show program's version number and exit
Examples
Basic Usage
# Count lines in current directory
python3 ulc.py
# Count specific directory
python3 ulc.py /path/to/project
# Limit directory traversal depth
python3 ulc.py . --depth 3
Git Integration
# Auto-detects git repos and respects .gitignore
python3 ulc.py /path/to/git/repo
# Force git mode even outside repos
python3 ulc.py . --git
# Disable git integration completely
python3 ulc.py . --no-git
Ignore Files with .ulcignore
ULC supports a .ulcignore file to exclude specific files and directories from counting. This works independently of git and is useful for:
- Non-git repositories
- Additional exclusions beyond .gitignore
- Temporary exclusions during development
Create a .ulcignore file in your project root:
# Example .ulcignore
node_modules/
dist/
*.min.js
test_data/
*.generated.*
See .ulcignore.example for a comprehensive template.
Output Customization
# Sort by file count instead of lines
python3 ulc.py . --sort files
# Sort alphabetically by language
python3 ulc.py . --sort name
# Disable colored output for scripts
python3 ulc.py . --no-color
# Verbose mode shows each file processed
python3 ulc.py . --verbose
Advanced Features
# Debug mode shows unknown file extensions
python3 ulc.py . --debug
# Comprehensive mode with GitHub Linguist
python3 ulc.py . --comprehensive
# Custom linguist path
python3 ulc.py . --comprehensive --linguist-path /custom/path/linguist
Platform Compatibility
| Platform | Environment | 119+ Native Languages | GitHub Linguist (400+) | Status |
|---|---|---|---|---|
| Linux | WSL2 (Ubuntu 24.04) | โ Validated | ๐ Not tested | โ Validated |
| Linux | Native Ubuntu 22.04+ | ๐ Not tested | ๐ Not tested | ๐ Pending |
| Linux | RHEL/CentOS 8+ | ๐ Not tested | ๐ Not tested | ๐ Pending |
| Linux | Debian 11+ | ๐ Not tested | ๐ Not tested | ๐ Pending |
| macOS | macOS 12+ (Intel) | ๐ Not tested | ๐ Not tested | ๐ Pending |
| macOS | macOS 14+ (Apple Silicon) | ๐ Not tested | ๐ Not tested | ๐ Pending |
| Windows | Windows 10/11 (native) | ๐ Not tested | ๐ Not tested | ๐ Pending |
| Windows | Git Bash | ๐ Not tested | ๐ Not tested | ๐ Pending |
| Windows | PowerShell 7 | ๐ Not tested | ๐ Not tested | ๐ Pending |
| Docker | Alpine Linux | ๐ Not tested | ๐ Not tested | ๐ Pending |
| Docker | Ubuntu based | ๐ Not tested | ๐ Not tested | ๐ Pending |
| Cloud | GitHub Codespaces | ๐ Not tested | ๐ Not tested | ๐ Pending |
| Cloud | GitLab CI/CD | ๐ Not tested | ๐ Not tested | ๐ Pending |
| BSD | FreeBSD 13+ | ๐ Not tested | ๐ Not tested | ๐ Pending |
Notes:
- Native language support: 119+ languages without external dependencies
- GitHub Linguist integration: Optional, adds 400+ languages (requires Ruby)
- Python requirement: 3.8+ (tested with 3.12)
Supported Languages
Modern Languages (Web, Mobile, Systems)
Python, JavaScript, TypeScript, Vue, Svelte, Java, C, C++, C#, Go, Rust, Ruby, PHP, Swift, Kotlin, Scala, Dart, R, Julia
Shell & Scripting
Shell (bash, zsh, fish), PowerShell, Perl, Lua
Data & Config
SQL, HTML, CSS, Markdown, YAML, JSON, XML, TOML, INI, Properties
Legacy Systems
COBOL, FORTRAN, Pascal, Ada, Assembly, BASIC, Visual Basic
Domain-Specific
VHDL, Verilog, MATLAB, Mathematica, SAS, SPSS, AutoLISP, OpenSCAD
And 80+ more languages...
Sample Output
Universal Language Counter Results:
--------------------------------------------------------------------------------
Language Files Total Code Comments %
--------------------------------------------------------------------------------
Total 156 45,234 38,891 4,829 100.0%
--------------------------------------------------------------------------------
Python 89 28,456 25,123 2,891 62.9 %
JavaScript 23 8,234 7,456 623 18.2 %
Markdown 18 4,891 4,201 0 10.8 %
JSON 12 2,134 2,134 0 4.7 %
Shell 8 891 634 89 2.0 %
YAML 6 628 567 226 1.4 %
--------------------------------------------------------------------------------
Directory: /path/to/project (git repository - respecting .gitignore)
Language Detection Features
Smart Conflict Resolution
.hfiles: Distinguishes C, C++, and Objective-C by content analysis.mfiles: Separates MATLAB from Objective-C based on syntax patterns.rfiles: Identifies R vs Rebol using language-specific keywords.plfiles: Differentiates Perl from Prolog through code analysis
Special File Handling
- Makefiles: Recognizes various Makefile variants
- Dockerfiles: Detects Dockerfile patterns
- READMEs: Identifies documentation files
- Git config: Classifies
.gitignore,.gitattributesas configuration - Shebang detection: Analyzes
#!/usr/bin/envheaders for extensionless scripts
Architecture
Thread-Safe Design
- Instance-based color management
- Thread-safe linguist integration
- Concurrent-safe file processing
Security Features
- Input validation for external tool paths
- Command injection prevention
- Safe file encoding detection
- Path traversal protection
Performance Optimizations
- Symlink cycle detection
- Binary file filtering
- Efficient directory traversal
- Configurable depth limits
Requirements
- Python 3.6+ (required)
- chardet (optional, recommended for encoding detection)
- github-linguist (optional, for 400+ language support)
Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
MIT License - see LICENSE file for details.
Version History
- v1.0.0 - Initial release with 119+ language support
- Smart conflict resolution
- Git integration
- Cross-platform support
- Thread-safe architecture
- Security hardening
Universal Language Counter - Professional code analysis made simple.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nxlc-0.1.0.tar.gz.
File metadata
- Download URL: nxlc-0.1.0.tar.gz
- Upload date:
- Size: 31.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a77bd2bab6b6518593cb1aa2fa403686a3c6094b87eceed4f7965c2ad67aaf93
|
|
| MD5 |
4ce0172dee1875cf23a967195f1f35d4
|
|
| BLAKE2b-256 |
dd43d87c8a3230638a22d7bba0c53b0eca456fb2c1c44b19490b37c31a93bbe8
|
File details
Details for the file nxlc-0.1.0-py3-none-any.whl.
File metadata
- Download URL: nxlc-0.1.0-py3-none-any.whl
- Upload date:
- Size: 21.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
60b49c1751af6357b5fecbcb01bc5fda652abee3391476affa34fac346a2f5f4
|
|
| MD5 |
823a33dc4e45d497c1fa5c90eb3032a1
|
|
| BLAKE2b-256 |
82ccc32780ac6eb062b845b230200abc52d2d9650645f471caa1f86324824301
|