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

Commit

Permalink
update output messages
Browse files Browse the repository at this point in the history
  • Loading branch information
martinnirtl committed Feb 20, 2020
1 parent bf38443 commit 719e00c
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 18 deletions.
2 changes: 1 addition & 1 deletion internal/commands/configcmd/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ var setCmd = &cobra.Command{
setConfigVar(varname[0])

message := fmt.Sprintf("Set %s: %s", chalk.Cyan.Color(varname[0]), chalk.Cyan.Color(viper.GetString(varname[0])))
err := fmt.Errorf("Failed to set '%s'", varname[0])
err := fmt.Errorf("Failed to set: %s", varname[0])
config.Save(message, err)
}
},
Expand Down
2 changes: 1 addition & 1 deletion internal/commands/downcmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ var DownCommand = &cobra.Command{
os.Exit(0)
}

utils.Success("Executed 'docker-compose down'")
utils.Success(fmt.Sprintf("Executed %s.", chalk.Bold.TextStyle("docker-compose down")))

viper.Set(fmt.Sprintf("envs.%s.running", activeEnv.GetName()), false)
config.Save("", fmt.Errorf("Failed to set running to 'false' [%s]", activeEnv))
Expand Down
2 changes: 1 addition & 1 deletion internal/commands/envcmd/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ var pullCommand = &cobra.Command{
}
utils.ErrorAndExit(err)

utils.Success(fmt.Sprintf("Pulled env: %s", env.GetName()))
utils.Success(fmt.Sprintf("Pulled environment %s.", chalk.Bold.TextStyle(env.GetName())))
},
}

Expand Down
2 changes: 1 addition & 1 deletion internal/commands/profilecmd/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ var createCmd = &cobra.Command{

viper.Set(fmt.Sprintf("envs.%s.profiles.%s", activeEnv.GetName(), profileName), selected)

config.Save(fmt.Sprintf("Saved profile to %s environment: %s", chalk.Bold.TextStyle(activeEnv.GetName()), chalk.Cyan.Color(profileName)), fmt.Errorf("Failed to save profile '%s'", profileName))
config.Save(fmt.Sprintf("Saved profile to %s environment: %s", chalk.Bold.TextStyle(activeEnv.GetName()), chalk.Cyan.Color(profileName)), fmt.Errorf("Failed to save profile: %s", profileName))
},
}

Expand Down
4 changes: 2 additions & 2 deletions internal/commands/profilecmd/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var deleteCmd = &cobra.Command{
Example: "dockma profile delete",
Args: func(cmd *cobra.Command, args []string) error {
if len(args) == 1 && !config.GetActiveEnv().HasProfile(args[0]) {
return fmt.Errorf("No such profile '%s'", args[0])
return fmt.Errorf("No such profile: %s", args[0])
}

if len(args) > 1 {
Expand Down Expand Up @@ -58,7 +58,7 @@ var deleteCmd = &cobra.Command{

viper.Set(fmt.Sprintf("envs.%s.profiles", activeEnv.GetName()), profileMap)

config.Save(fmt.Sprintf("Deleted profile from %s environment: %s", chalk.Bold.TextStyle(activeEnv.GetName()), chalk.Cyan.Color(profileName)), fmt.Errorf("Failed to delete profile '%s'", profileName))
config.Save(fmt.Sprintf("Deleted profile from %s environment: %s", chalk.Bold.TextStyle(activeEnv.GetName()), chalk.Cyan.Color(profileName)), fmt.Errorf("Failed to delete profile: %s", profileName))
},
}

Expand Down
4 changes: 2 additions & 2 deletions internal/commands/profilecmd/rename.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var renameCmd = &cobra.Command{
Example: "dockma profile rename",
Args: func(cmd *cobra.Command, args []string) error {
if len(args) == 1 && !config.GetActiveEnv().HasProfile(args[0]) {
return fmt.Errorf("No such profile '%s'", args[0])
return fmt.Errorf("No such profile: %s", args[0])
}

if len(args) > 1 {
Expand Down Expand Up @@ -59,7 +59,7 @@ var renameCmd = &cobra.Command{

viper.Set(fmt.Sprintf("envs.%s.profiles", activeEnv.GetName()), profileMap)

config.Save(fmt.Sprintf("Renamed profile from %s to %s %s", chalk.Cyan.Color(renameProfile), chalk.Cyan.Color(profileName), chalk.Bold.TextStyle(fmt.Sprintf("[%s]", activeEnv.GetName()))), fmt.Errorf("Failed to rename profile '%s'", renameProfile))
config.Save(fmt.Sprintf("Renamed profile from %s to %s %s", chalk.Cyan.Color(renameProfile), chalk.Cyan.Color(profileName), chalk.Bold.TextStyle(fmt.Sprintf("[%s]", activeEnv.GetName()))), fmt.Errorf("Failed to rename profile: %s", renameProfile))
},
}

Expand Down
4 changes: 2 additions & 2 deletions internal/commands/profilecmd/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var updateCmd = &cobra.Command{
Example: "dockma profile update",
Args: func(cmd *cobra.Command, args []string) error {
if len(args) == 1 && !config.GetActiveEnv().HasProfile(args[0]) {
return fmt.Errorf("No such profile '%s'", args[0])
return fmt.Errorf("No such profile: %s", args[0])
}

if len(args) > 1 {
Expand Down Expand Up @@ -64,7 +64,7 @@ var updateCmd = &cobra.Command{

viper.Set(fmt.Sprintf("envs.%s.profiles.%s", activeEnv.GetName(), profileName), selected)

config.Save(fmt.Sprintf("Updated profile in %s: %s", chalk.Bold.TextStyle(activeEnv.GetName()), chalk.Cyan.Color(profileName)), fmt.Errorf("Failed to update profile '%s'", profileName))
config.Save(fmt.Sprintf("Updated profile in %s: %s", chalk.Bold.TextStyle(activeEnv.GetName()), chalk.Cyan.Color(profileName)), fmt.Errorf("Failed to update profile: %s", profileName))
},
}

Expand Down
8 changes: 4 additions & 4 deletions internal/commands/upcmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ var UpCommand = &cobra.Command{
output, err := envcmd.Pull(envHomeDir, hideCmdOutput, false)
if err != nil && hideCmdOutput {
fmt.Print(string(output))
utils.Warn("Could not execute 'git pull'.")
utils.Warn(fmt.Sprintf("Could not execute %s.", chalk.Bold.TextStyle("git pull")))

fmt.Println() // Add empty line for better readability
} else {
utils.Success(fmt.Sprintf("Pulled environment: %s", activeEnv.GetName()))
utils.Success(fmt.Sprintf("Pulled environment %s.", chalk.Bold.TextStyle(activeEnv.GetName())))
}
}

Expand Down Expand Up @@ -144,8 +144,8 @@ var UpCommand = &cobra.Command{
utils.ErrorAndExit(err)

viper.Set(fmt.Sprintf("envs.%s.running", activeEnv.GetName()), true)
config.Save("", fmt.Errorf("Failed to set running to 'true' [%s]", activeEnv.GetName()))
config.Save("", fmt.Errorf("Failed to save running state of environment: %s", activeEnv.GetName()))

utils.Success("Successfully executed 'docker-compose up'")
utils.Success(fmt.Sprintf("Executed %s.", chalk.Bold.TextStyle("docker-compose up")))
},
}
3 changes: 2 additions & 1 deletion internal/survey/survey.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/AlecAivazis/survey/v2"
"github.com/AlecAivazis/survey/v2/terminal"
"github.com/martinnirtl/dockma/internal/utils"
"github.com/ttacon/chalk"
)

// NameRegex should be used to verify all names
Expand All @@ -23,7 +24,7 @@ func ValidateName(val interface{}) error {
}

if !match {
return fmt.Errorf("'%s' has to comply with regex /%s/", name, NameRegex)
return fmt.Errorf("%s has to comply with regex: %s", chalk.Bold.TextStyle(name), NameRegex)
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/dockercompose/dockercompose.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func getDockerCompose(filepath string, override bool) (*viper.Viper, error) {
readError := temp.ReadInConfig()

if readError != nil {
return nil, fmt.Errorf("Could not read %s file", fileName)
return nil, fmt.Errorf("Could not read file: %s", fileName)
}

return temp, nil
Expand Down
4 changes: 2 additions & 2 deletions pkg/externalcommand/externalcommand.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ func Execute(command string, timebridger Timebridger, logfile string) ([]byte, e
fileError := ioutil.WriteFile(logfile, output, 0644)

if fileError != nil {
return output, fmt.Errorf("Could not save output to logfile")
return output, fmt.Errorf("Could not save output to logfile: %s", logfile)
}
}

if commandError != nil {
return output, fmt.Errorf("Could not run command '%s'", command)
return output, fmt.Errorf("Could not run command: %s", command)
}

return output, nil
Expand Down

0 comments on commit 719e00c

Please sign in to comment.