-
Notifications
You must be signed in to change notification settings - Fork 455
/
cli.go
45 lines (41 loc) · 1.11 KB
/
cli.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
package cli
import (
"log"
"github.com/mitchellh/cli"
"github.com/spiffe/spire/cmd/spire-agent/cli/api"
"github.com/spiffe/spire/cmd/spire-agent/cli/healthcheck"
"github.com/spiffe/spire/cmd/spire-agent/cli/run"
"github.com/spiffe/spire/pkg/common/version"
)
func Run(args []string) int {
c := cli.NewCLI("spire-agent", version.Version())
c.Args = args
c.Commands = map[string]cli.CommandFactory{
"api fetch": func() (cli.Command, error) {
return api.NewFetchX509Command(), nil
},
"api fetch x509": func() (cli.Command, error) {
return api.NewFetchX509Command(), nil
},
"api fetch jwt": func() (cli.Command, error) {
return api.NewFetchJWTCommand(), nil
},
"api validate jwt": func() (cli.Command, error) {
return api.NewValidateJWTCommand(), nil
},
"api watch": func() (cli.Command, error) {
return &api.WatchCLI{}, nil
},
"run": func() (cli.Command, error) {
return &run.RunCLI{}, nil
},
"healthcheck": func() (cli.Command, error) {
return healthcheck.NewHealthCheckCommand(), nil
},
}
exitStatus, err := c.Run()
if err != nil {
log.Println(err)
}
return exitStatus
}