-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
61 lines (49 loc) · 997 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package main
import (
"os"
"github.com/jessevdk/go-flags"
"github.com/wellsjo/SuperSearch/src/logger"
"github.com/wellsjo/SuperSearch/src/search"
)
func main() {
var (
pattern string
location string
opts search.Options
)
parser := flags.NewParser(&opts, flags.Default)
parser.Usage = "[OPTIONS] PATTERN [PATH]"
args, err := parser.Parse()
if err != nil {
logger.Fail(err.Error())
}
if len(args) == 0 {
parser.WriteHelp(os.Stdout)
os.Exit(0)
} else {
pattern = args[0]
}
if len(args) > 1 {
location = args[1]
}
if pattern == "" {
parser.WriteHelp(os.Stdout)
os.Exit(0)
}
if location == "" {
location, err = os.Getwd()
if err != nil {
logger.Fail(err.Error())
}
}
search.New(&search.Options{
Pattern: pattern,
Location: location,
IgnoreCase: opts.IgnoreCase,
Quiet: opts.Quiet,
Hidden: opts.Hidden,
Unrestricted: opts.Unrestricted,
Debug: opts.Debug,
ShowStats: opts.ShowStats,
}).Run()
}