55 "fmt"
66 "mainak55512/stto/utils"
77 "os"
8+ "path"
89 "runtime"
910 "runtime/debug"
1011 "sync"
@@ -14,7 +15,8 @@ import (
1415
1516func main () {
1617
17- debug .SetGCPercent (- 1 )
18+ // Optimizing GC
19+ debug .SetGCPercent (1000 )
1820
1921 // Limiting os threads to available cpu
2022 runtime .GOMAXPROCS (runtime .NumCPU ())
@@ -35,7 +37,13 @@ func main() {
3537 var file_details []utils.File_details
3638 var folder_count int32
3739 var is_git_initialized bool = false
38- files , err := utils .GetFiles (& is_git_initialized , & folder_count )
40+ var folder_name string = ""
41+ if len (flag .Args ()) > 0 {
42+ folder_name = flag .Args ()[0 ]
43+ }
44+
45+ files , err := utils .GetFiles (& is_git_initialized , & folder_count , folder_name )
46+
3947 if err != nil {
4048 fmt .Println ("Error:" , err )
4149 return
@@ -57,7 +65,6 @@ func main() {
5765 }
5866 wg .Wait ()
5967
60- runtime .GC ()
6168 table := tablewriter .NewWriter (os .Stdout )
6269 table .SetHeader ([]string {
6370 "File Type" ,
@@ -67,6 +74,7 @@ func main() {
6774 "comments" ,
6875 "Code" ,
6976 })
77+ table .SetFooterAlignment (2 )
7078
7179 // if not extension is provided via --ext flag
7280 if * lang == "none" {
@@ -80,22 +88,31 @@ func main() {
8088 fmt .Sprint (item .Code ),
8189 })
8290 }
83- table .Render ()
8491
8592 total_files ,
8693 total_lines ,
8794 total_gaps ,
8895 total_comments ,
8996 total_code := utils .GetTotalCounts (& file_details )
9097
98+ table .SetFooter ([]string {
99+ "Total:" ,
100+ fmt .Sprint (total_files ),
101+ fmt .Sprint (total_lines ),
102+ fmt .Sprint (total_gaps ),
103+ fmt .Sprint (total_comments ),
104+ fmt .Sprint (total_code ),
105+ })
106+ table .Render ()
107+
91108 pwd , e := os .Getwd ()
92109
93110 if e != nil {
94111 fmt .Println (e )
95112 os .Exit (1 )
96113 }
97- fmt . Println ( " \n Stats: \n =======" )
98- fmt .Println ("Present working directory: " , pwd )
114+
115+ fmt .Println ("Target directory: " , path . Join ( pwd , folder_name ) )
99116
100117 // total subdirectories are folder_count-1,
101118 // as present working directory is not a subdirectory
@@ -104,16 +121,6 @@ func main() {
104121 folder_count - 1 ,
105122 is_git_initialized ,
106123 )
107- fmt .Printf (
108- "\n Total files:\t %10d\t Total lines:\t %10d\n " +
109- "Total gaps:\t %10d\t Total comments:\t %10d\n " +
110- "Total code:\t %10d\n " ,
111- total_files ,
112- total_lines ,
113- total_gaps ,
114- total_comments ,
115- total_code ,
116- )
117124 } else {
118125
119126 // will be set to true if atleast one file
0 commit comments