-
Notifications
You must be signed in to change notification settings - Fork 0
/
mktmpio.go
103 lines (92 loc) · 2.48 KB
/
mktmpio.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
// Copyright Datajin Technologies, Inc. 2015,2016. All rights reserved.
// Use of this source code is governed by an Artistic-2
// license that can be found in the LICENSE file.
package main
import (
"os"
"path"
"runtime"
"time"
"github.com/mktmpio/cli/commands"
"github.com/urfave/cli"
)
// overriden at compile time (-ldflags "-X main.version=V main.commit=C")
var (
version = "0.0.0"
commit = "HEAD"
buildtime = "0000-00-00T00:00:00Z"
t, terr = time.Parse("2006-01-02T15:04:05Z", buildtime)
)
const appHelpTemplate = `NAME:
{{.Name}} - {{.Usage}}
USAGE:
{{.HelpName}}
{{- if .Flags }} [global options] {{- end -}}
{{- if .Commands}} command [command options] {{- end -}}
{{- if .ArgsUsage}} {{.ArgsUsage}} {{- else }} [arguments...] {{- end}}
GLOBAL OPTIONS:
{{range .Flags}}
{{- .}}
{{end}}
COMMANDS:
{{range .Commands}}
{{- join .Names ", "}}{{ "\t" }}{{.Usage}}
{{end}}
BUGS:
Report to https://github.com/mktmpio/cli/issues
VERSION:
Version: {{.Version}}
Compiled: {{.Compiled}}
COPYRIGHT:
{{.Copyright}}
`
func mktmpioApp() *cli.App {
// overrides for some variables exposed by urfave/cli
cli.AppHelpTemplate = appHelpTemplate
cli.VersionFlag.Name = "version"
cli.HelpFlag.Name = "help"
return &cli.App{
Name: "mktmpio",
HelpName: path.Base(os.Args[0]),
Usage: "create, destroy, and manage mktmpio database servers",
Version: version + " (built with " + runtime.Compiler + ", " + runtime.Version() + ")",
Compiled: t,
Copyright: "Copyright Datajin Technologies, Inc. 2015,2016. All rights reserved.",
BashComplete: cli.DefaultAppComplete,
Action: commands.ShellCommand.Action,
Before: commands.PopulateConfig,
Writer: os.Stdout,
Commands: []cli.Command{
commands.ConfigCommand,
commands.ListCommand,
commands.RemoveCommand,
commands.ShellCommand,
commands.LegalCommand,
},
Flags: []cli.Flag{
cli.BoolFlag{
Name: "debug, d",
Usage: "Enable extra verbose logging",
EnvVar: "MKTMPIO_DEBUG",
},
cli.StringFlag{
Name: "token",
Usage: "API token for making requests to mktmpio service",
EnvVar: "MKTMPIO_TOKEN",
Value: "TOKEN",
},
cli.StringFlag{
Name: "url",
Usage: "override the URL for the mktmpio service",
EnvVar: "MKTMPIO_URL",
Value: "URL",
},
},
Authors: []cli.Author{
{Name: "Ryan Graham", Email: "[email protected]"},
},
}
}
func main() {
mktmpioApp().Run(os.Args)
}