-
Notifications
You must be signed in to change notification settings - Fork 0
/
root.go
66 lines (52 loc) · 1.49 KB
/
root.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
package cmd
import (
"fmt"
"os"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"bunnyshell.com/cli/cmd/component"
"bunnyshell.com/cli/cmd/configure"
"bunnyshell.com/cli/cmd/environment"
"bunnyshell.com/cli/cmd/event"
"bunnyshell.com/cli/cmd/organization"
"bunnyshell.com/cli/cmd/project"
"bunnyshell.com/cli/cmd/remote_development"
"bunnyshell.com/cli/cmd/version"
"bunnyshell.com/cli/pkg/lib"
"bunnyshell.com/cli/pkg/lib/cliconfig"
"bunnyshell.com/cli/pkg/net"
)
// rootCmd represents the base command when called without any subcommands
var rootCmd = &cobra.Command{
Use: "bunnyshell-cli",
Short: "Bunnyshell CLI",
}
func Execute() {
err := rootCmd.Execute()
if err != nil {
os.Exit(1)
}
}
func init() {
cobra.OnInitialize(initConfig)
rootCmd.AddCommand(configure.GetMainCommand())
rootCmd.AddCommand(organization.GetMainCommand())
rootCmd.AddCommand(project.GetMainCommand())
rootCmd.AddCommand(environment.GetMainCommand())
rootCmd.AddCommand(component.GetMainCommand())
rootCmd.AddCommand(event.GetMainCommand())
rootCmd.AddCommand(version.GetMainCommand())
rootCmd.AddCommand(remote_development.GetMainCommand())
lib.CLIContext.SetGlobalFlags(rootCmd)
}
func initConfig() {
if lib.CLIContext.NoProgress {
net.DefaultSpinnerTransport.Disabled = true
}
cobra.CheckErr(cliconfig.FindConfigFile())
viper.SetEnvPrefix(lib.ENV_PREFIX)
viper.AutomaticEnv()
if lib.CLIContext.Verbosity != 0 {
fmt.Fprintln(os.Stdout, "Using config file:", viper.ConfigFileUsed())
}
}