forked from boyter/scc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
171 lines (165 loc) · 3.23 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
package main
import (
"github.com/boyter/scc/processor"
"github.com/spf13/cobra"
"os"
)
//go:generate go run scripts/include.go
func main() {
//f, _ := os.Create("scc.pprof")
//pprof.StartCPUProfile(f)
//defer pprof.StopCPUProfile()
rootCmd := &cobra.Command{
Use: "scc",
Short: "scc [FILE or DIRECTORY]",
Long: "Sloc, Cloc and Code. Count lines of code in a directory with complexity estimation.\nBen Boyter <ben@boyter.org> + Contributors",
Version: processor.Version,
Run: func(cmd *cobra.Command, args []string) {
processor.DirFilePaths = args
processor.ConfigureGc()
processor.ConfigureLazy(true)
processor.Process()
},
}
flags := rootCmd.PersistentFlags()
flags.Int64Var(
&processor.AverageWage,
"avg-wage",
56286,
"average wage value used for basic COCOMO calculation",
)
flags.BoolVar(
&processor.DisableCheckBinary,
"binary",
false,
"disable binary file detection",
)
flags.BoolVar(
&processor.Files,
"by-file",
false,
"display output for every file",
)
flags.BoolVar(
&processor.Ci,
"ci",
false,
"enable CI output settings where stdout is ASCII",
)
flags.BoolVar(
&processor.Ignore,
"no-ignore",
false,
"disables .ignore file logic",
)
flags.BoolVar(
&processor.GitIgnore,
"no-gitignore",
false,
"disables .gitignore file logic",
)
flags.BoolVar(
&processor.Debug,
"debug",
false,
"enable debug output",
)
flags.StringSliceVar(
&processor.PathBlacklist,
"exclude-dir",
[]string{".git", ".hg", ".svn"},
"directories to exclude",
)
flags.IntVar(
&processor.GcFileCount,
"file-gc-count",
10000,
"number of files to parse before turning the GC on",
)
flags.StringVarP(
&processor.Format,
"format",
"f",
"tabular",
"set output format [tabular, wide, json, csv, cloc-yaml]",
)
flags.StringSliceVarP(
&processor.WhiteListExtensions,
"include-ext",
"i",
[]string{},
"limit to file extensions [comma separated list: e.g. go,java,js]",
)
flags.BoolVarP(
&processor.Languages,
"languages",
"l",
false,
"print supported languages and extensions",
)
flags.BoolVar(
&processor.Cocomo,
"no-cocomo",
false,
"remove COCOMO calculation output",
)
flags.BoolVarP(
&processor.Complexity,
"no-complexity",
"c",
false,
"skip calculation of code complexity",
)
flags.BoolVarP(
&processor.Duplicates,
"no-duplicates",
"d",
false,
"remove duplicate files from stats and output",
)
flags.StringArrayVarP(
&processor.Exclude,
"not-match",
"M",
[]string{},
"ignore files and directories matching regular expression",
)
flags.StringVarP(
&processor.FileOutput,
"output",
"o",
"",
"output filename (default stdout)",
)
flags.StringVarP(
&processor.SortBy,
"sort",
"s",
"files",
"column to sort by [files, name, lines, blanks, code, comments, complexity]",
)
flags.BoolVarP(
&processor.Trace,
"trace",
"t",
false,
"enable trace output. Not recommended when processing multiple files",
)
flags.BoolVarP(
&processor.Verbose,
"verbose",
"v",
false,
"verbose output",
)
flags.BoolVarP(
&processor.More,
"wide",
"w",
false,
"wider output with additional statistics (implies --complexity)",
)
if err := rootCmd.Execute(); err != nil {
os.Exit(1)
}
}