forked from boyter/scc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
131 lines (124 loc) · 3.87 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
package main
import (
"github.com/boyter/scc/processor"
"github.com/urfave/cli"
"os"
)
//go:generate go run scripts/include.go
func main() {
//f, _ := os.Create("scc.pprof")
//pprof.StartCPUProfile(f)
//defer pprof.StopCPUProfile()
// defer profile.Start(profile.CPUProfile).Stop()
// defer profile.Start(profile.MemProfile).Stop()
app := cli.NewApp()
app.EnableBashCompletion = true
app.Name = "scc"
app.Version = "1.9.0"
app.Usage = "Sloc, Cloc and Code. Count lines of code in a directory with complexity estimation."
app.UsageText = "scc DIRECTORY"
app.Flags = []cli.Flag{
cli.BoolFlag{
Name: "languages",
Usage: "Print out supported languages and their extensions",
Destination: &processor.Languages,
},
cli.StringFlag{
Name: "format, f",
Usage: "Set output format [possible values: tabular, wide, json, csv]",
Destination: &processor.Format,
Value: "tabular",
},
cli.StringFlag{
Name: "output, o",
Usage: "Set output file if not set will print to stdout `FILE`",
Destination: &processor.FileOutput,
},
cli.StringFlag{
Name: "pathblacklist, pbl",
Usage: "Which directories should be ignored as comma separated list",
Value: ".git,.hg,.svn",
Destination: &processor.PathBlacklist,
},
cli.StringFlag{
Name: "sort, s",
Usage: "Sort languages / files based on column [possible values: files, name, lines, blanks, code, comments, complexity]",
Value: "files",
Destination: &processor.SortBy,
},
cli.StringFlag{
Name: "whitelist, wl",
Usage: "Restrict file extensions to just those provided as a comma separated list E.G. go,java,js",
Value: "",
Destination: &processor.WhiteListExtensions,
},
cli.BoolFlag{
Name: "files",
Usage: "Set to specify you want to see the output for every file",
Destination: &processor.Files,
},
cli.BoolFlag{
Name: "verbose, v",
Usage: "Set to enable verbose output",
Destination: &processor.Verbose,
},
cli.BoolFlag{
Name: "duplicates, d",
Usage: "Set to check for and remove duplicate files from stats and output",
Destination: &processor.Duplicates,
},
cli.BoolFlag{
Name: "complexity, c",
Usage: "Set to skip complexity calculations note will be overridden if wide is set",
Destination: &processor.Complexity,
},
cli.BoolFlag{
Name: "wide, w",
Usage: "Set to check produce more output such as complexity and code vs complexity ranking. Same as setting format to wide",
Destination: &processor.More,
},
cli.Int64Flag{
Name: "averagewage, aw",
Usage: "Set as integer to set the average wage used for basic COCOMO calculation",
Destination: &processor.AverageWage,
Value: 56286,
},
cli.BoolFlag{
Name: "cocomo, co",
Usage: "Set to check remove COCOMO calculation output",
Destination: &processor.Cocomo,
},
cli.IntFlag{
Name: "filegccount, fgc",
Usage: "How many files to parse before turning the GC on",
Destination: &processor.GcFileCount,
Value: 10000,
},
cli.BoolFlag{
Name: "binary",
Usage: "Set to disable binary file detection",
Destination: &processor.DisableCheckBinary,
},
cli.BoolFlag{
Name: "debug",
Usage: "Set to enable debug output",
Destination: &processor.Debug,
},
cli.BoolFlag{
Name: "trace",
Usage: "Set to enable trace output, not recommended for multiple files",
Destination: &processor.Trace,
},
}
// Override the default version flag because we want v for verbose
cli.VersionFlag = cli.BoolFlag{
Name: "version, ver",
Usage: "Print the version",
}
app.Action = func(c *cli.Context) error {
processor.DirFilePaths = c.Args()
processor.Process()
return nil
}
app.Run(os.Args)
}