-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
81 lines (72 loc) · 1.42 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
package main
import (
"os"
"path/filepath"
"runtime"
"strings"
"github.com/urfave/cli"
)
// Version is current version. Overwirte by release.sh
var Version = "0.0.1"
var exit = os.Exit
var isV = false
var isD = false
var envShell = "bash"
var envHome = ""
var envCommand = ""
var envExt = ""
func main() {
app := cli.NewApp()
//app.Name = "dcenv"
app.Usage = "Simple Docker Environment Management"
app.Version = Version
app.Flags = []cli.Flag{
cli.BoolFlag{
Name: "dryrun, d",
Usage: "Don't create/write any file and io.(not impl yet)",
Destination: &isD,
},
cli.BoolFlag{
Name: "verbose, V",
Usage: "print verbose mode.",
Destination: &isV,
},
}
app.Commands = []cli.Command{
commandGlobal,
commandExec,
commandRehash,
commandLocal,
commandSystem,
commandCommand,
commandInstall,
commandUninstall,
commandTag,
commandYard,
commandPush,
commandLogout,
}
envExt = ""
if runtime.GOOS == `windows` {
envExt = ".bat"
}
envCommand = os.Getenv("DCENV_COMMAND") + envExt
envShell = os.Getenv("DCENV_SHELL")
if envShell == "" {
if runtime.GOOS == `windows` {
envShell = `windows`
} else {
envShell = `bash`
}
}
envHome = os.Getenv("DCENV_HOME")
if envHome == "" {
str, err := os.Executable()
if err != nil {
exit(1)
return
}
envHome = strings.TrimSuffix(filepath.Dir(str), string(os.PathSeparator)+"files")
}
app.Run(os.Args)
}