-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.go
53 lines (44 loc) · 914 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
package main
import (
"fmt"
"os"
cli "github.com/jhunt/go-cli"
"github.com/thomasmitchell/bosh-complete/version"
)
var opts options
type options struct {
Debug bool `cli:"-d, --debug"`
Complete struct{} `cli:"complete"`
BashSource struct{} `cli:"bash-source"`
ZshSource struct{} `cli:"zsh-source"`
Version struct{} `cli:"version"`
}
func main() {
command, args, err := cli.Parse(&opts)
if err != nil {
panic("Could not init cli parser: " + err.Error())
}
if os.Getenv("BOSH_COMPLETE_DEBUG") != "" {
opts.Debug = true
}
if opts.Debug {
log.TurnOn()
}
log.Write("")
switch command {
case "complete":
doComplete(args)
case "bash-source":
doBashSource()
case "zsh-source":
//For my weird friends Nic and Long
doZshSource()
case "version":
doVersion()
default:
panic("Unknown command: " + command)
}
}
func doVersion() {
fmt.Println(version.Version)
}