forked from boyter/scc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
104 lines (96 loc) · 2.93 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
package main
import (
"github.com/boyter/scc/processor"
"github.com/urfave/cli"
"os"
// "runtime/pprof"
)
//go:generate go run scripts/include.go
func main() {
// f, _ := os.Create("scc.pprof")
// pprof.StartCPUProfile(f)
// defer pprof.StopCPUProfile()
app := cli.NewApp()
app.EnableBashCompletion = true
app.Name = "scc"
app.Version = "1.0.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.StringFlag{
Name: "pathblacklist, pbl",
Usage: "Which directories should be ignored as comma seperated 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 seperated 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",
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.BoolFlag{
Name: "debug",
Usage: "Set to enable debug output",
Destination: &processor.Debug,
},
cli.BoolFlag{
Name: "trace",
Usage: "Set to enable trace output, not reccomended 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)
}