-
Notifications
You must be signed in to change notification settings - Fork 7
/
commands.go
66 lines (57 loc) · 2.09 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
62
63
64
65
66
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package main
import (
"os"
cmdAppEntrypoint "github.com/hashicorp/consul-ecs/subcommand/app-entrypoint"
cmdController "github.com/hashicorp/consul-ecs/subcommand/controller"
cmdEnvoyEntrypoint "github.com/hashicorp/consul-ecs/subcommand/envoy-entrypoint"
cmdHealthSync "github.com/hashicorp/consul-ecs/subcommand/health-sync"
cmdMeshInit "github.com/hashicorp/consul-ecs/subcommand/mesh-init"
cmdNetDial "github.com/hashicorp/consul-ecs/subcommand/net-dial"
cmdVersion "github.com/hashicorp/consul-ecs/subcommand/version"
"github.com/hashicorp/consul-ecs/version"
"github.com/mitchellh/cli"
)
// Commands is the mapping of all available consul-ecs commands.
var Commands map[string]cli.CommandFactory
func init() {
ui := &cli.BasicUi{Writer: os.Stdout, ErrorWriter: os.Stderr}
Commands = map[string]cli.CommandFactory{
"version": func() (cli.Command, error) {
return &cmdVersion.Command{UI: ui, Version: version.GetHumanVersion()}, nil
},
"mesh-init": func() (cli.Command, error) {
return &cmdMeshInit.Command{UI: ui}, nil
},
"controller": func() (cli.Command, error) {
return &cmdController.Command{UI: ui}, nil
},
"envoy-entrypoint": func() (cli.Command, error) {
return &cmdEnvoyEntrypoint.Command{UI: ui}, nil
},
"app-entrypoint": func() (cli.Command, error) {
return &cmdAppEntrypoint.Command{UI: ui}, nil
},
"net-dial": func() (cli.Command, error) {
return &cmdNetDial.Command{UI: ui}, nil
},
"health-sync": func() (cli.Command, error) {
return &cmdHealthSync.Command{UI: ui}, 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{}{}
var include []string
for k := range Commands {
if _, ok := hidden[k]; !ok {
include = append(include, k)
}
}
return cli.FilteredHelpFunc(include, cli.BasicHelpFunc("consul-ecs"))
}