Files
kmanage/cmd/root.go
T

50 lines
1.1 KiB
Go

package cmd
import (
"os"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
var rootCmd = &cobra.Command{
Use: "kmanage",
Short: "kmanage - CLI management tool for Komodo stacks and Git infrastructure",
Long: `kmanage is a fast, lightweight CLI tool for managing Komodo Core stacks,
Git repositories, webhooks, and pull-request branch automation across multiple Git providers.`,
PersistentPreRun: func(cmd *cobra.Command, args []string) {
// Silence usage text on runtime execution errors once flags have been validated
cmd.SilenceUsage = true
},
}
// Execute executes the root cobra command.
func Execute() {
if err := rootCmd.Execute(); err != nil {
os.Exit(1)
}
}
func init() {
cobra.OnInitialize(initConfig)
rootCmd.PersistentFlags().Bool("no-header", false, "Omit table headers from tabular output")
}
func initConfig() {
home, err := os.UserHomeDir()
if err != nil {
return
}
viper.AddConfigPath(home)
viper.SetConfigType("yaml")
viper.SetConfigName(".kmanage")
viper.SetEnvPrefix("KMANAGE")
viper.AutomaticEnv()
if err := viper.ReadInConfig(); err != nil {
// Config file might not exist yet
}
}