-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
103 lines (83 loc) · 1.84 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
package main
import (
"log"
"os"
"strconv"
"github.com/codegangsta/cli"
)
const (
dirMode os.FileMode = 0755 // Default mode for directories
)
var (
logger = log.New(os.Stderr, "", 0)
verbose = false
CachePath = os.Getenv("HACHER_PATH")
CacheKeep = 3
)
func initClient() {
if len(CachePath) < 1 {
printFatal("Env variable HACHER_PATH is not set. Point it to the cache directory.")
}
if len(os.Getenv("HACHER_KEEP")) > 0 {
if i, err := strconv.Atoi(os.Getenv("HACHER_KEEP")); err == nil {
CacheKeep = i
}
}
}
func main() {
initClient()
app := cli.NewApp()
app.Name = "Hacher"
app.Usage = "A simple CLI tool to cache project artifacts."
app.Author = "The Dockbit Team"
app.Version = "0.1.0"
// Alphabetically ordered list of commands
app.Flags = []cli.Flag{
cli.BoolFlag{
Name: "verbose, x",
Usage: "Verbose mode",
},
}
app.Commands = []cli.Command{
{
Name: "get",
Usage: "Gets cache content by a given key.",
Action: cmdGet,
Flags: []cli.Flag{
cli.StringFlag{
Name: "k, key",
Usage: "Cache key",
},
cli.StringFlag{
Name: "f, file",
Usage: "Path to comma-separated dependency file(s) to track for changes.",
},
cli.StringFlag{
Name: "e, env",
Usage: "Comma-separated dependency env variable(s) to track for changes.",
},
},
},
{
Name: "set",
Usage: "Saves cache content for a given key.",
Action: cmdSet,
Flags: []cli.Flag{
cli.StringFlag{
Name: "k, key",
Usage: "Cache key",
},
cli.StringFlag{
Name: "f, file",
Usage: "Path to comma-separated dependency file(s) to track for changes.",
},
cli.StringFlag{
Name: "e, env",
Usage: "Comma-separated dependency env variable(s) to track for changes.",
},
},
},
}
app.Run(os.Args)
}