-
Notifications
You must be signed in to change notification settings - Fork 5
/
main.go
51 lines (41 loc) · 1.35 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
51
package main
import (
"fmt"
"os"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/pulumi/pulumictl/cmd/pulumictl/copyright"
"github.com/pulumi/pulumictl/cmd/pulumictl/create"
"github.com/pulumi/pulumictl/cmd/pulumictl/dispatch"
"github.com/pulumi/pulumictl/cmd/pulumictl/get"
"github.com/pulumi/pulumictl/cmd/pulumictl/version"
"github.com/pulumi/pulumictl/pkg/contract"
)
var (
githubToken string
debug bool
)
func configureCLI() *cobra.Command {
rootCommand := &cobra.Command{
Use: "pulumictl",
Long: "A swiss army knife for Pulumi development",
}
rootCommand.AddCommand(get.Command())
rootCommand.AddCommand(create.Command())
rootCommand.AddCommand(version.Command())
rootCommand.AddCommand(dispatch.Command())
rootCommand.AddCommand(copyright.Command())
rootCommand.PersistentFlags().StringVarP(&githubToken, "token", "t", "", "a github token to use for making API calls to GitHub.")
rootCommand.PersistentFlags().BoolVarP(&debug, "debug", "D", false, "enable debug logging")
viper.BindEnv("debug", "PULUMICTL_DEBUG")
viper.BindEnv("token", "GITHUB_TOKEN")
viper.BindPFlag("debug", rootCommand.PersistentFlags().Lookup("debug"))
return rootCommand
}
func main() {
rootCommand := configureCLI()
if err := rootCommand.Execute(); err != nil {
contract.IgnoreIoError(fmt.Fprintf(os.Stderr, "%s", err))
os.Exit(1)
}
}