-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
37 lines (31 loc) · 943 Bytes
/
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
package main
import (
"github.com/go-pkgz/lgr"
"github.com/jessevdk/go-flags"
"os"
)
type commonOptions struct {
Verbose bool `short:"v" long:"verbose" description:"Show current file"`
DatabasePath string `short:"d" long:"database" required:"true" description:"path to result file"`
}
var options struct {
Collect collectCommand `command:"collect" description:"gather data to database"`
PrintCmd printCommand `command:"print" description:"print content of database"`
FindDuplicatesCmd dupsCommand `command:"dups" description:"find duplicates in database basing on file size"`
}
var flagParser = flags.NewParser(&options, flags.Default)
func main() {
_, err := flagParser.Parse()
if err != nil {
if flagsErr, ok := err.(*flags.Error); ok && flagsErr.Type == flags.ErrHelp {
os.Exit(0)
} else {
os.Exit(1)
}
}
}
func setupLogs(verbose bool) {
if verbose {
lgr.Setup(lgr.Debug)
}
}