-
Notifications
You must be signed in to change notification settings - Fork 5
/
main.go
100 lines (93 loc) · 1.89 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
package main
import (
"fmt"
"github.com/spf13/cobra"
"os"
)
func main() {
//f, _ := os.Create("profile.pprof")
//_ = pprof.StartCPUProfile(f)
//defer pprof.StopCPUProfile()
rootCmd := &cobra.Command{
Use: "dcd",
Short: "dcd",
Long: fmt.Sprintf("dcd\nVersion %s\nBen Boyter <[email protected]>", version),
Version: version,
Run: func(cmd *cobra.Command, args []string) {
dirFilePaths = args
if len(dirFilePaths) == 0 {
dirFilePaths = append(dirFilePaths, ".")
}
process()
},
}
flags := rootCmd.PersistentFlags()
flags.IntVarP(
&minMatchLength,
"match-length",
"m",
6,
"min match length",
)
flags.BoolVar(
&processSameFile,
"process-same-file",
false,
"",
)
flags.StringSliceVarP(
&allowListExtensions,
"include-ext",
"i",
[]string{},
"limit to file extensions [comma separated list: e.g. go,java,js]",
)
flags.BoolVar(
&ignoreIgnoreFile,
"no-ignore",
false,
"disables .ignore file logic",
)
flags.BoolVar(
&ignoreGitIgnore,
"no-gitignore",
false,
"disables .gitignore file logic",
)
flags.StringSliceVarP(
&locationExcludePattern,
"exclude-pattern",
"x",
[]string{},
"file and directory locations matching case sensitive patterns will be ignored [comma separated list: e.g. vendor,_test.go]",
)
flags.IntVar(
&minifiedLineByteLength,
"min-line-length",
255,
"number of bytes per average line for file to be considered minified",
)
flags.Int64Var(
&maxReadSizeBytes,
"max-read-size-bytes",
10000000,
"number of bytes to read into a file with the remaining content ignored",
)
flags.BoolVarP(
&verbose,
"verbose",
"v",
false,
"verbose output",
)
flags.Uint8VarP(
&fuzzValue,
"fuzz",
"f",
0,
"fuzzy value where higher numbers allow increasingly fuzzy lines to match, values 0-255 where 0 indicates exact match",
)
if err := rootCmd.Execute(); err != nil {
os.Exit(1)
}
}