-
Notifications
You must be signed in to change notification settings - Fork 7
/
main.go
50 lines (42 loc) · 1.06 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
package main
import (
"fmt"
"os"
flags "github.com/jessevdk/go-flags"
"github.com/nerdalize/nerd/command"
"github.com/nerdalize/nerd/nerd"
"github.com/nerdalize/nerd/nerd/conf"
"github.com/mitchellh/cli"
)
var (
name = "nerd"
version = nerd.BuiltFromSourceVersion
commit = "0000000"
)
func init() {
opts := new(command.ConfOpts)
_, err := flags.NewParser(opts, flags.None).ParseArgs(os.Args[1:])
if err == nil {
conf.SetLocation(opts.ConfigFile)
nerd.SetupLogging(opts.VerboseOutput, opts.JSONOutput)
nerd.VersionMessage(version)
}
}
func main() {
c := cli.NewCLI(name, fmt.Sprintf("%s (%s)", version, commit))
c.Args = os.Args[1:]
c.Commands = map[string]cli.CommandFactory{
"login": command.LoginFactory(),
"upload": command.UploadFactory(),
"run": command.RunFactory(),
"logs": command.LogsFactory(),
"work": command.WorkFactory(),
"status": command.StatusFactory(),
"download": command.DownloadFactory(),
}
status, err := c.Run()
if err != nil {
fmt.Fprintf(os.Stderr, "%s: %s", name, err)
}
os.Exit(status)
}