1- ## 📦 extliner
1+ # 📦 extliner
22
3- ** extliner** is a lightweight Python package that counts lines in files (with and without empty lines) grouped by file extension — perfect for analyzing codebases or text -heavy directories.
3+ ** extliner** is a lightweight Python package that recursively counts lines in files — distinguishing between total lines and non- empty lines — grouped by file extension. It's perfect for analyzing codebases, writing statistics, or cleaning up documentation -heavy directories.
44
55---
66
7- ### 🚀 Features
8-
9- * 📂 Recursive directory traversal
10- * 🔍 Counts:
11-
12- * Total lines ** with** whitespace
13- * Total lines ** excluding** empty lines
14- * 🎯 Extension-based grouping (` .py ` , ` .txt ` , ` NO_EXT ` , etc.)
15- * 🚫 Option to ** ignore specific file extensions**
16- * 📊 Beautiful ** tabulated output**
17- * 🧩 Easily extensible class-based design
18- * 🧪 CLI support
7+ ## 🚀 Features
8+
9+ - 📂 Recursive directory scanning
10+ - 🧮 Counts:
11+ - Total lines (with whitespace)
12+ - Non-empty lines (ignores blank lines)
13+ - 🔠 Groups results by file extension (` .py ` , ` .js ` , ` NO_EXT ` , etc.)
14+ - 🚫 Support for ignoring specific extensions or folders
15+ - 📊 Output formats:
16+ - Pretty CLI table
17+ - JSON / CSV / Markdown exports
18+ - 🧩 Clean, extensible class-based design
19+ - 🧪 Fully tested with ` unittest `
20+ - 🔧 CLI and Python API support
1921
2022---
2123
22- ### 📥 Installation
24+ ## 📥 Installation
25+
26+ Install via pip:
2327
2428``` bash
2529pip install extliner
2630```
2731
28- ( Or if using locally during development:)
32+ Or install locally for development:
2933
3034``` bash
3135git clone https://github.com/extliner/extliner.git
@@ -35,62 +39,107 @@ pip install -e .
3539
3640---
3741
38- ### 🧑💻 Usage
42+ ## ⚙️ CLI Usage
3943
40- #### ✅ CLI
44+ ### ✅ Basic
4145
4246``` bash
43- extliner -d < directory_path> --ignore .log .json
47+ extliner -d < directory_path>
4448```
4549
46- #### Example
50+ ### 🔍 Ignoring Extensions
4751
4852``` bash
4953extliner -d ./myproject --ignore .md .log
5054```
5155
52- #### Output
56+ ### Ignoring Folders
57+
58+ ``` bash
59+ extliner -d ./myproject --folders .venv __pycache__
60+ ```
61+
62+ ### 🧾 Output Example
5363
5464```
55- +------------+---------------+-------------------+--------------+
56- | Extension | With Spaces | Without Spaces | % of Total |
57- +------------+---------------+-------------------+--------------+
58- | .py | 320 | 280 | 65.31% |
59- | .txt | 170 | 150 | 34.69% |
60- +------------+---------------+-------------------+--------------+
65+ +-------------+---------------+------------------+---------+--------------+
66+ | Extension | With Spaces | Without Spaces | Files | % of Total |
67+ +=============+===============+==================+=========+==============+
68+ | .py | 443 | 362 | 7 | 32.15% |
69+ +-------------+---------------+------------------+---------+--------------+
70+ | no_ext | 361 | 287 | 8 | 26.20% |
71+ +-------------+---------------+------------------+---------+--------------+
72+ | .pyc | 151 | 125 | 3 | 10.96% |
73+ +-------------+---------------+------------------+---------+--------------+
6174```
6275
6376---
77+ ## 🧱 Python API
6478
65- ### 🧱 Python API
79+ ### ✅ Count Lines Programmatically
6680
6781``` python
68- from linecountx .main import LineCounter
82+ from extliner .main import LineCounter
6983from pathlib import Path
7084
7185counter = LineCounter(ignore_extensions = [" .log" , " .json" ])
7286result = counter.count_lines(Path(" ./your_directory" ))
7387
88+ # Output as JSON
7489print (counter.to_json(result))
90+
91+ # Output as Markdown
92+ print (counter.to_markdown(result))
93+
94+ # Output as CSV
95+ print (counter.to_csv(result))
7596```
7697
7798---
7899
79- ### ⚙️ Options
100+ ## 🛠️ Configuration Options
101+
102+ | Flag | Description | Example | Optioal/Required |
103+ | ----------- | --------------------------------- | ----------------------------- | ---------------- |
104+ | ` -d ` | Directory to scan | ` -d ./src ` | Required |
105+ | ` --ignore ` | File extensions to ignore | ` --ignore .log .md .json ` | Optional |
106+ | ` --folders ` | Folder names to ignore | ` --folders .venv __pycache__ ` | Optional |
107+
108+ ---
109+
110+ ## 📂 Supported Formats
80111
81- | Flag | Description | Example |
82- | ---------- | ---------------------------- | ------------------------- |
83- | ` -d ` | Directory to scan (required) | ` -d ./src ` |
84- | ` --ignore ` | File extensions to ignore | ` --ignore .log .md .json ` |
112+ | Output Method | Description |
113+ | ------------------- | ---------------------- |
114+ | ` to_json(data) ` | Returns JSON string |
115+ | ` to_csv(data) ` | Returns CSV string |
116+ | ` to_markdown(data) ` | Returns Markdown table |
85117
118+ ---
119+
120+ ## ✅ Testing
121+
122+ To run tests:
123+
124+ ``` bash
125+ python -m unittest discover tests
126+ ```
127+
128+ Or using ` pytest ` (if installed):
129+
130+ ``` bash
131+ pytest
132+ ```
133+
134+ ---
86135
87- ### 📄 License
136+ ## 📄 License
88137
89- MIT License
138+ This project is licensed under the MIT License.
90139
91140---
92141
93- ### 👨💻 Author
142+ ## 👨💻 Author
94143
95144Made with ❤️ by [ Deepak Raj] ( https://github.com/extliner )
96145
0 commit comments