Skip to content
This repository has been archived by the owner on Jun 9, 2022. It is now read-only.

Commit

Permalink
show old env name on env init cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
martinnirtl committed Mar 1, 2020
1 parent 3de8134 commit 142c7d4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions internal/commands/envcmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,19 @@ func runInitCommand(cmd *cobra.Command, args []string) {
config.Save(fmt.Sprintf("Initialized new environment: %s", chalk.Cyan.Color(envName)), fmt.Errorf("Failed to save newly created environment: %s", envName))

activeEnv := config.GetActiveEnv()
oldEnv := activeEnv.GetName()
oldEnvName := activeEnv.GetName()

set := true
if activeEnv.IsRunning() {
message := fmt.Sprintf("Currently active environment %s is %s. Set new environment %s active", chalk.Cyan.Color(oldEnv), chalk.Green.Color("running"), chalk.Cyan.Color(envName))
message := fmt.Sprintf("Currently active environment %s is %s. Set new environment %s active", chalk.Cyan.Color(oldEnvName), chalk.Green.Color("running"), chalk.Cyan.Color(envName))

set = survey.Confirm(message, false)
}

if set {
viper.Set("active", envName)

config.Save(fmt.Sprintf("Set active environment: %s", chalk.Cyan.Color(envName)), fmt.Errorf("Failed to set active environment: %s", envName))
config.Save(fmt.Sprintf("Set active environment: %s (old: %s)", chalk.Cyan.Color(envName), oldEnvName), fmt.Errorf("Failed to set active environment: %s", envName))
}

}

0 comments on commit 142c7d4

Please sign in to comment.