forked from hashicorp/consul-k8s
-
Notifications
You must be signed in to change notification settings - Fork 0
/
commands.go
61 lines (49 loc) · 1.74 KB
/
commands.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
package main
import (
"os"
cmdACLInit "github.com/hashicorp/consul-k8s/subcommand/acl-init"
cmdInjectConnect "github.com/hashicorp/consul-k8s/subcommand/inject-connect"
cmdServerACLInit "github.com/hashicorp/consul-k8s/subcommand/server-acl-init"
cmdSyncCatalog "github.com/hashicorp/consul-k8s/subcommand/sync-catalog"
cmdVersion "github.com/hashicorp/consul-k8s/subcommand/version"
"github.com/hashicorp/consul-k8s/version"
"github.com/mitchellh/cli"
)
// Commands is the mapping of all available consul-k8s commands.
var Commands map[string]cli.CommandFactory
func init() {
ui := &cli.BasicUi{Writer: os.Stdout, ErrorWriter: os.Stderr}
Commands = map[string]cli.CommandFactory{
"acl-init": func() (cli.Command, error) {
return &cmdACLInit.Command{UI: ui}, nil
},
"inject-connect": func() (cli.Command, error) {
return &cmdInjectConnect.Command{UI: ui}, nil
},
"server-acl-init": func() (cli.Command, error) {
return &cmdServerACLInit.Command{UI: ui}, nil
},
"sync-catalog": func() (cli.Command, error) {
return &cmdSyncCatalog.Command{UI: ui}, nil
},
"version": func() (cli.Command, error) {
return &cmdVersion.Command{UI: ui, Version: version.GetHumanVersion()}, nil
},
}
}
func helpFunc() cli.HelpFunc {
// This should be updated for any commands we want to hide for any reason.
// Hidden commands can still be executed if you know the command, but
// aren't shown in any help output. We use this for prerelease functionality
// or advanced features.
hidden := map[string]struct{}{
"inject-connect": struct{}{},
}
var include []string
for k := range Commands {
if _, ok := hidden[k]; !ok {
include = append(include, k)
}
}
return cli.FilteredHelpFunc(include, cli.BasicHelpFunc("consul-k8s"))
}