diff --git a/pkg/cmd/config.go b/pkg/cmd/config.go index c1a2496..1786637 100644 --- a/pkg/cmd/config.go +++ b/pkg/cmd/config.go @@ -49,10 +49,58 @@ var configSetCmd = &cobra.Command{ }, } +// configSetDevCmd represents the config set "dev" command +var configSetDevCmd = &cobra.Command{ + Use: "dev", + Short: "Set config information to dev environment", + Long: `Set config information to dev environment.`, + Run: func(cmd *cobra.Command, args []string) { + viper.Set("ClientID", "f9BSuAhmF8dmUtJWZyjAVJbGJWQMKsMW") + viper.Set("APIURL", "https://dev.snapmaster.io") + viper.Set("AuthDomain", "snapmaster-dev.auth0.com") + + // use viper to write the config to the file + err := viper.WriteConfig() + if err != nil { + fmt.Printf("snap: could not write config file\nerror: %s\n", err) + os.Exit(1) + } else { + fmt.Printf("snap: updated config\n") + } + + printConfig() + }, +} + +// configSetProdCmd represents the config set "prod" command +var configSetProdCmd = &cobra.Command{ + Use: "prod", + Short: "Set config information to production environment", + Long: `Set config information to production environment.`, + Run: func(cmd *cobra.Command, args []string) { + viper.Set("ClientID", "O4e0z2Ky5DSvjzw3N5YLgtrz1GGltkOb") + viper.Set("APIURL", "https://www.snapmaster.io") + viper.Set("AuthDomain", "snapmaster.auth0.com") + + // use viper to write the config to the file + err := viper.WriteConfig() + if err != nil { + fmt.Printf("snap: could not write config file\nerror: %s\n", err) + os.Exit(1) + } else { + fmt.Printf("snap: updated config\n") + } + + printConfig() + }, +} + func init() { rootCmd.AddCommand(configCmd) configCmd.AddCommand(configGetCmd) configCmd.AddCommand(configSetCmd) + configSetCmd.AddCommand(configSetDevCmd) + configSetCmd.AddCommand(configSetProdCmd) configSetCmd.Flags().StringP("api-url", "", "", "API URL (defaults to https://dev.snapmaster.io)") configSetCmd.Flags().StringP("client-id", "", "", "Auth0 Client ID (required for any non-default API URL)") diff --git a/pkg/cmd/root.go b/pkg/cmd/root.go index d2f4a02..d808813 100644 --- a/pkg/cmd/root.go +++ b/pkg/cmd/root.go @@ -52,9 +52,9 @@ func init() { // initConfig reads in config file and ENV variables if set. func initConfig() { // set some default values - viper.SetDefault("ClientID", "f9BSuAhmF8dmUtJWZyjAVJbGJWQMKsMW") - viper.SetDefault("APIURL", "https://dev.snapmaster.io") - viper.SetDefault("AuthDomain", "snapmaster-dev.auth0.com") + viper.SetDefault("ClientID", "O4e0z2Ky5DSvjzw3N5YLgtrz1GGltkOb") + viper.SetDefault("APIURL", "https://www.snapmaster.io") + viper.SetDefault("AuthDomain", "snapmaster.auth0.com") viper.SetDefault("RedirectURL", "http://localhost:8085") if cfgFile != "" { diff --git a/pkg/version/version.go b/pkg/version/version.go index d4371de..69d86d1 100644 --- a/pkg/version/version.go +++ b/pkg/version/version.go @@ -1,7 +1,7 @@ package version // Version number -var Version string = "0.5.4" +var Version string = "0.5.5" // GitHash of the last commit var GitHash string