Skip to content

Commit 8eac92c

Browse files
authored
Merge pull request #22 from mainak55512/enhancement
More file support added and done refactoring
2 parents bf70de1 + 2fdf53e commit 8eac92c

File tree

10 files changed

+274
-79
lines changed

10 files changed

+274
-79
lines changed

README.md

Lines changed: 13 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -15,50 +15,24 @@ Command-line utility written in Go to check total line of code in a file present
1515
- github.com/mattn/go-runewidth v0.0.9
1616
- github.com/olekukonko/tablewriter v0.0.5
1717

18+
## Benchmark
19+
20+
#### Benchmark was run on the clone of '[Redis](https://github.com/redis/redis)' repository
21+
22+
![Demo](./resources/benchmark.gif)
23+
**N.B: stto is no way near the more established options like 'scc' or 'tokei' in terms of features. It is in early development stage and isn't production ready.
24+
25+
All the tools read over 1.5k files
26+
![stto](./resources/stto_redis.png)
27+
![scc](./resources/scc_redis.png)
28+
![tokei](./resources/tokei_redis.png)
1829

1930
## Usage
2031
### usage 1:
21-
```bash
22-
❯ stto
23-
+--------------------+------------+-----------------+-----+----------+------+
24-
| FILE TYPE | FILE COUNT | NUMBER OF LINES | GAP | COMMENTS | CODE |
25-
+--------------------+------------+-----------------+-----+----------+------+
26-
| vim_tutorial.c.swp | 1 | 3 | 0 | 0 | 3 |
27-
| c | 46 | 1113 | 23 | 3 | 1087 |
28-
| py | 14 | 165 | 6 | 6 | 153 |
29-
| class | 1 | 8 | 0 | 0 | 8 |
30-
| m | 1 | 4 | 0 | 0 | 4 |
31-
| out | 1 | 6 | 0 | 0 | 6 |
32-
| js | 1 | 21 | 2 | 0 | 19 |
33-
| java | 1 | 21 | 3 | 1 | 17 |
34-
| css | 1 | 14 | 0 | 0 | 14 |
35-
| html | 1 | 13 | 0 | 0 | 13 |
36-
| cbl | 1 | 10 | 0 | 0 | 10 |
37-
| jl | 2 | 16 | 1 | 0 | 15 |
38-
| txt | 1 | 19 | 3 | 0 | 16 |
39-
+--------------------+------------+-----------------+-----+----------+------+
40-
41-
Stats:
42-
=======
43-
Present working directory: /home/mainak/programs/others
44-
Total sub-directories: 4
45-
Git initialized: false
46-
47-
Total files: 72 Total lines: 1413
48-
Total gaps: 38 Total comments: 10
49-
Total code: 1365
50-
```
32+
![stto_usage_1](./resources/stto_usage_1.png)
5133

5234
### Usage 2:
53-
```bash
54-
❯ stto -ext c
55-
+-----------+------------+-----------------+-----+----------+------+
56-
| FILE TYPE | FILE COUNT | NUMBER OF LINES | GAP | COMMENTS | CODE |
57-
+-----------+------------+-----------------+-----+----------+------+
58-
| c | 46 | 1113 | 23 | 2 | 1088 |
59-
+-----------+------------+-----------------+-----+----------+------+
60-
```
61-
** Only single line comments are supported
35+
![stto_usage_2](./resources/stto_usage_2.png)
6236

6337
## 🚀 About Me
6438
I'm a Tech enthusiast and a hobby programmer.

main.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@ import (
66
"mainak55512/stto/utils"
77
"os"
88
"runtime"
9+
"runtime/debug"
910
"sync"
1011

1112
"github.com/olekukonko/tablewriter"
1213
)
1314

1415
func main() {
1516

17+
debug.SetGCPercent(-1)
18+
1619
// Limiting os threads to available cpu
1720
runtime.GOMAXPROCS(runtime.NumCPU())
1821

@@ -54,6 +57,7 @@ func main() {
5457
}
5558
wg.Wait()
5659

60+
runtime.GC()
5761
table := tablewriter.NewWriter(os.Stdout)
5862
table.SetHeader([]string{
5963
"File Type",

resources/benchmark.gif

11.3 MB
Loading

resources/scc_redis.png

81.2 KB
Loading

resources/stto_redis.png

67.4 KB
Loading

resources/stto_usage_1.png

43.4 KB
Loading

resources/stto_usage_2.png

8.26 KB
Loading

resources/tokei_redis.png

70.2 KB
Loading

utils/lookup.go

Lines changed: 250 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package utils
22

33
type Comment_Map struct {
4-
supports_multi bool
5-
single_comment string
6-
multi_comment_open string
4+
supports_multi bool
5+
single_comment string
6+
multi_comment_open string
77
multi_comment_close string
88
}
99

@@ -13,37 +13,251 @@ value:Comment_Map struct
1313
*/
1414

1515
var lookup_map map[string]Comment_Map = map[string]Comment_Map{
16-
"go": { true,"//","/*","*/"},
17-
"c": { true,"//","/*","*/"},
18-
"cpp": { true,"//","/*","*/"},
19-
"js": { true,"//","/*","*/"},
20-
"ts": { true,"//","/*","*/"},
21-
"jsx": { true,"//","/*","*/"},
22-
"tsx": { true,"//","/*","*/"},
23-
"java": { true,"//","/*","*/"},
24-
"rs": { true,"//","/*","*/"},
25-
"swift": { true,"//","/*","*/"},
26-
"kt": { true,"//","/*","*/"},
27-
"php": { true,"//","/*","*/"},
28-
"m": { true,"//","/*","*/"},
29-
"groovy": { true,"//","/*","*/"},
30-
"cs": { true,"//","/*","*/"},
31-
"scala": { true,"//","/*","*/"},
32-
"zig": { true,"//","/*","*/"},
33-
"gleam": { true,"//","/*","*/"},
34-
"py": { true,"#",`"""`,`"""`},
35-
"r": { false,"#","",""},
36-
"rb": { false,"#","",""},
37-
"sh": { true,"#",": '","'"},
38-
"pl": { true,"#","/*","*/"},
39-
"ex": { false,"#","",""},
40-
"exs": { false,"#","",""},
41-
"jl": { true,"#","#=","=#"},
42-
"lua": { true,"--","--[[","]]--"},
43-
"hs": { true,"--","/*","*/"},
44-
"sql": { true,"--","/*","*/"},
45-
"cbl": { true,"*","/*","*/"},
46-
"erl": { true,"%","=begin","=cut"},
47-
"clj": { false,";;","",""},
48-
"lisp": { false,";","",""},
16+
"abap": {false, "*", "", ""},
17+
"as": {true, "//", "/*", "*/"},
18+
"ada": {false, "--", "", ""},
19+
"adb": {false, "--", "", ""},
20+
"ads": {false, "--", "", ""},
21+
"pad": {false, "--", "", ""},
22+
"agda": {true, "--", "{-", "-}"},
23+
"crn": {false, "#", "", ""},
24+
"als": {true, "//", "/*", "*/"},
25+
"aidl": {true, "//", "/*", "*/"},
26+
"apl": {false, "⍝", "", ""},
27+
"aplf": {false, "⍝", "", ""},
28+
"apln": {false, "⍝", "", ""},
29+
"aplc": {false, "⍝", "", ""},
30+
"dyalog": {false, "⍝", "", ""},
31+
"applescript": {true, "--", "(*", "*)"},
32+
"art": {false, ";", "", ""},
33+
"asa": {false, "'", "", ""},
34+
"asp": {false, "'", "", ""},
35+
"asax": {true, "", "<%", "%>"},
36+
"ascx": {true, "", "<%", "%>"},
37+
"asmx": {true, "", "<%", "%>"},
38+
"master": {true, "", "<%", "%>"},
39+
"aspx": {true, "", "<%", "%>"},
40+
"sitemap": {true, "", "<%", "%>"},
41+
"webinfo": {true, "", "<%", "%>"},
42+
"asm": {true, ";", "/*", "*/"},
43+
"s": {true, ";", "/*", "*/"},
44+
"awk": {false, "#", "", ""},
45+
"bt": {true, "//", "/*", "*/"},
46+
"bash": {false, "#", "", ""},
47+
"bash_login": {false, "#", "", ""},
48+
"bash_logout": {false, "#", "", ""},
49+
"bash_profile": {false, "#", "", ""},
50+
"bashrc": {false, "#", "", ""},
51+
"bas": {false, "'", "", ""},
52+
"bat": {false, "REM", "", ""},
53+
"btm": {false, "REM", "", ""},
54+
"cmd": {false, "REM", "", ""},
55+
"bzl": {false, "#", "", ""},
56+
"build.bazel": {false, "#", "", ""},
57+
"build": {false, "#", "", ""},
58+
"workspace": {false, "#", "", ""},
59+
"bb": {false, "#", "", ""},
60+
"bbapend": {false, "#", "", ""},
61+
"bbclass": {false, "#", "", ""},
62+
"bst": {false, "#", "", ""},
63+
"boo": {true, "//", "/*", "*/"},
64+
"bsq": {false, "//", "", ""},
65+
"go": {true, "//", "/*", "*/"},
66+
"c": {true, "//", "/*", "*/"},
67+
"ec": {true, "//", "/*", "*/"},
68+
"pgc": {true, "//", "/*", "*/"},
69+
"h": {true, "//", "/*", "*/"},
70+
"hh": {true, "//", "/*", "*/"},
71+
"hpp": {true, "//", "/*", "*/"},
72+
"hxx": {true, "//", "/*", "*/"},
73+
"inl": {true, "//", "/*", "*/"},
74+
"ipp": {true, "//", "/*", "*/"},
75+
"csh": {false, "#", "", ""},
76+
"cpp": {true, "//", "/*", "*/"},
77+
"cc": {true, "//", "/*", "*/"},
78+
"cxx": {true, "//", "/*", "*/"},
79+
"c++": {true, "//", "/*", "*/"},
80+
"pcc": {true, "//", "/*", "*/"},
81+
"ino": {true, "//", "/*", "*/"},
82+
"cassius": {true, "//", "/*", "*/"},
83+
"ceylon": {true, "//", "/*", "*/"},
84+
"chpl": {true, "//", "/*", "*/"},
85+
"circom": {true, "//", "/*", "*/"},
86+
"ch": {true, "//", "/*", "*/"},
87+
"prg": {true, "//", "/*", "*/"},
88+
"cabal": {true, "--", "{-", "-}"},
89+
"dhall": {true, "--", "{-", "-}"},
90+
"elm": {true, "--", "{-", "-}"},
91+
"pures": {true, "--", "{-", "-}"},
92+
"cognet": {false, "--", "", ""},
93+
"cu": {true, "//", "/*", "*/"},
94+
"css": {true, "//", "/*", "*/"},
95+
"js": {true, "//", "/*", "*/"},
96+
"mjs": {true, "//", "/*", "*/"},
97+
"ts": {true, "//", "/*", "*/"},
98+
"jsx": {true, "//", "/*", "*/"},
99+
"tsx": {true, "//", "/*", "*/"},
100+
"java": {true, "//", "/*", "*/"},
101+
"jsp": {true, "//", "/*", "*/"},
102+
"rs": {true, "//", "/*", "*/"},
103+
"swift": {true, "//", "/*", "*/"},
104+
"kt": {true, "//", "/*", "*/"},
105+
"kts": {true, "//", "/*", "*/"},
106+
"php": {true, "//", "/*", "*/"},
107+
"m": {true, "//", "/*", "*/"},
108+
"groovy": {true, "//", "/*", "*/"},
109+
"grt": {true, "//", "/*", "*/"},
110+
"gtpl": {true, "//", "/*", "*/"},
111+
"gvy": {true, "//", "/*", "*/"},
112+
"cs": {true, "//", "/*", "*/"},
113+
"csx": {true, "//", "/*", "*/"},
114+
"scala": {true, "//", "/*", "*/"},
115+
"zig": {true, "//", "/*", "*/"},
116+
"gleam": {true, "//", "/*", "*/"},
117+
"d": {true, "//", "/*", "*/"},
118+
"dart": {true, "//", "/*", "*/"},
119+
"dts": {true, "//", "/*", "*/"},
120+
"dtsi": {true, "//", "/*", "*/"},
121+
"dm": {true, "//", "/*", "*/"},
122+
"odin": {true, "//", "/*", "*/"},
123+
"dot": {true, "//", "/*", "*/"},
124+
"fidl": {true, "//", "/*", "*/"},
125+
"fsh": {true, "//", "/*", "*/"},
126+
"cj": {true, "//", "/*", "*/"},
127+
"jai": {true, "//", "/*", "*/"},
128+
"julius": {true, "//", "/*", "*/"},
129+
"fsl": {false, "//", "", ""},
130+
"gradle": {false, "//", "", ""},
131+
"cairo": {false, "//", "", ""},
132+
"fxml": {false, "", "<!--", "-->"},
133+
"py": {true, "#", `"""`, `"""`},
134+
"pyx": {true, "#", `"""`, `"""`},
135+
"pxi": {true, "#", `"""`, `"""`},
136+
"pxd": {true, "#", `"""`, `"""`},
137+
"ipynb": {false, "", "", ""},
138+
"jpynb": {false, "", "", ""},
139+
"graphql": {true, "#", `"""`, `"""`},
140+
"r": {false, "#", "", ""},
141+
"rb": {false, "#", "", ""},
142+
"cmake": {false, "#", "", ""},
143+
"capnp": {false, "#", "", ""},
144+
"cmakelists.txt": {false, "#", "", ""},
145+
"fish": {false, "#", "", ""},
146+
"ini": {false, "#", "", ""},
147+
"janet": {false, "#", "", ""},
148+
"justfile": {false, "#", "", ""},
149+
"ksh": {false, "#", "", ""},
150+
"k": {false, "/", "", ""},
151+
"haml": {false, "-#", "", ""},
152+
"hamlet": {true, "", "<!--", "-->"},
153+
"html": {true, "", "<!--", "-->"},
154+
"sh": {true, "#", ": '", "'"},
155+
"pl": {true, "#", "/*", "*/"},
156+
"ex": {false, "#", "", ""},
157+
"exs": {false, "#", "", ""},
158+
"gemfile": {false, "#", "", ""},
159+
"gitignore": {false, "#", "", ""},
160+
"luna": {false, "#", "", ""},
161+
"m4": {false, "#", "", ""},
162+
"meson.build": {false, "#", "", ""},
163+
"meson_options.txt": {false, "#", "", ""},
164+
"jl": {true, "#", "#=", "=#"},
165+
"lua": {true, "--", "--[[", "]]--"},
166+
"hs": {true, "--", "/*", "*/"},
167+
"sql": {true, "--", "/*", "*/"},
168+
"fnc": {true, "--", "/*", "*/"},
169+
"pkb": {true, "--", "/*", "*/"},
170+
"pks": {true, "--", "/*", "*/"},
171+
"prc": {true, "--", "/*", "*/"},
172+
"trg": {true, "--", "/*", "*/"},
173+
"vw": {true, "--", "/*", "*/"},
174+
"cbl": {true, "*", "/*", "*/"},
175+
"ql": {true, "*", "/*", "*/"},
176+
"qll": {true, "*", "/*", "*/"},
177+
"erl": {true, "%", "=begin", "=cut"},
178+
"hrl": {true, "%", "=begin", "=cut"},
179+
"pp": {true, "#", "=begin", "=end"},
180+
"clj": {false, ";", "", ""},
181+
"cljc": {false, ";", "", ""},
182+
"cljs": {false, ";", "", ""},
183+
"coffee": {true, "#", "###", "###"},
184+
"md": {false, "", "", ""},
185+
"markdown": {false, "", "", ""},
186+
"txt": {false, "", "", ""},
187+
"text": {false, "", "", ""},
188+
"json": {false, "", "", ""},
189+
"jsonl": {false, "", "", ""},
190+
"jsonc": {true, "//", "/*", "*/"},
191+
"jsonnet": {true, "//", "/*", "*/"},
192+
"libsonnet": {true, "//", "/*", "*/"},
193+
"lds": {true, "//", "/*", "*/"},
194+
"less": {true, "//", "/*", "*/"},
195+
"lucius": {true, "//", "/*", "*/"},
196+
"mq4": {true, "//", "/*", "*/"},
197+
"mq5": {true, "//", "/*", "*/"},
198+
"proto": {true, "//", "/*", "*/"},
199+
"nix": {true, "//", "/*", "*/"},
200+
"qcl": {true, "//", "/*", "*/"},
201+
"qml": {true, "//", "/*", "*/"},
202+
"l": {true, "", "/*", "*/"},
203+
"yaml": {false, "#", "", ""},
204+
"yml": {false, "#", "", ""},
205+
"nim": {false, "#", "", ""},
206+
"prql": {false, "#", "", ""},
207+
"lisp": {false, ";", "", ""},
208+
"fs": {true, "//", "(*", "*)"},
209+
"fsi": {true, "//", "(*", "*)"},
210+
"fsx": {true, "//", "(*", "*)"},
211+
"fsscript": {true, "//", "(*", "*)"},
212+
"pas": {true, "//", "(*", "*)"},
213+
"fst": {true, "", "(*", "*)"},
214+
"f": {false, "!", "", ""},
215+
"for": {false, "!", "", ""},
216+
"ftn": {false, "!", "", ""},
217+
"f77": {false, "!", "", ""},
218+
"f03": {false, "!", "", ""},
219+
"pfo": {false, "!", "", ""},
220+
"f08": {false, "!", "", ""},
221+
"f90": {false, "!", "", ""},
222+
"f95": {false, "!", "", ""},
223+
"tmpl": {true, "", "{{/*", "*/}}"},
224+
"gohtml": {true, "", "{{/*", "*/}}"},
225+
"gotxt": {true, "", "{{/*", "*/}}"},
226+
"qs": {false, "//", "", ""},
227+
"jade": {false, "//-", "", ""},
228+
"jinja": {true, "", "{#", "#}"},
229+
"j2": {true, "", "{#", "#}"},
230+
"jinja2": {true, "", "{#", "#}"},
231+
"tex": {true, "%", "", ""},
232+
"lean": {true, "--", "/-", "-/"},
233+
"hlean": {true, "--", "/-", "-/"},
234+
"m3": {true, "#", "(*", "*)"},
235+
"mg": {true, "#", "(*", "*)"},
236+
"ig": {true, "#", "(*", "*)"},
237+
"i3": {true, "#", "(*", "*)"},
238+
"ml": {true, "", "(*", "*)"},
239+
"mli": {true, "", "(*", "*)"},
240+
"ps1": {true, "#", "<#", "#>"},
241+
"psm1": {true, "#", "<#", "#>"},
242+
"p": {true, "%", "/*", "*/"},
243+
"pro": {true, "%", "/*", "*/"},
244+
"tcl": {false, "#", "", ""},
245+
"Makefile": {false, "#", "", ""},
246+
"makefile": {false, "#", "", ""},
247+
"mak": {false, "#", "", ""},
248+
"bp": {false, "#", "", ""},
249+
"mk": {false, "#", "", ""},
250+
"csproj": {true, "", "<!--", "-->"},
251+
"vbproj": {true, "", "<!--", "-->"},
252+
"fsproj": {true, "", "<!--", "-->"},
253+
"vcproj": {true, "", "<!--", "-->"},
254+
"vcxproj": {true, "", "<!--", "-->"},
255+
"vcxproj.filters": {true, "", "<!--", "-->"},
256+
"ilproj": {true, "", "<!--", "-->"},
257+
"props": {true, "", "<!--", "-->"},
258+
"rdlc": {true, "", "<!--", "-->"},
259+
"resx": {true, "", "<!--", "-->"},
260+
"settings": {true, "", "<!--", "-->"},
261+
"sln": {true, "", "<!--", "-->"},
262+
"targets": {true, "", "<!--", "-->"},
49263
}

0 commit comments

Comments
 (0)