1
- ## 📦 extliner
1
+ # 📦 extliner
2
2
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.
4
4
5
5
---
6
6
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
19
21
20
22
---
21
23
22
- ### 📥 Installation
24
+ ## 📥 Installation
25
+
26
+ Install via pip:
23
27
24
28
``` bash
25
29
pip install extliner
26
30
```
27
31
28
- ( Or if using locally during development:)
32
+ Or install locally for development:
29
33
30
34
``` bash
31
35
git clone https://github.com/extliner/extliner.git
@@ -35,62 +39,107 @@ pip install -e .
35
39
36
40
---
37
41
38
- ### 🧑💻 Usage
42
+ ## ⚙️ CLI Usage
39
43
40
- #### ✅ CLI
44
+ ### ✅ Basic
41
45
42
46
``` bash
43
- extliner -d < directory_path> --ignore .log .json
47
+ extliner -d < directory_path>
44
48
```
45
49
46
- #### Example
50
+ ### 🔍 Ignoring Extensions
47
51
48
52
``` bash
49
53
extliner -d ./myproject --ignore .md .log
50
54
```
51
55
52
- #### Output
56
+ ### Ignoring Folders
57
+
58
+ ``` bash
59
+ extliner -d ./myproject --folders .venv __pycache__
60
+ ```
61
+
62
+ ### 🧾 Output Example
53
63
54
64
```
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
+ +-------------+---------------+------------------+---------+--------------+
61
74
```
62
75
63
76
---
77
+ ## 🧱 Python API
64
78
65
- ### 🧱 Python API
79
+ ### ✅ Count Lines Programmatically
66
80
67
81
``` python
68
- from linecountx .main import LineCounter
82
+ from extliner .main import LineCounter
69
83
from pathlib import Path
70
84
71
85
counter = LineCounter(ignore_extensions = [" .log" , " .json" ])
72
86
result = counter.count_lines(Path(" ./your_directory" ))
73
87
88
+ # Output as JSON
74
89
print (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))
75
96
```
76
97
77
98
---
78
99
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
80
111
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 |
85
117
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
+ ---
86
135
87
- ### 📄 License
136
+ ## 📄 License
88
137
89
- MIT License
138
+ This project is licensed under the MIT License.
90
139
91
140
---
92
141
93
- ### 👨💻 Author
142
+ ## 👨💻 Author
94
143
95
144
Made with ❤️ by [ Deepak Raj] ( https://github.com/extliner )
96
145
0 commit comments