From ed2b527d74eaa29f5721f5ce86f0a7e7bd16cbfc Mon Sep 17 00:00:00 2001 From: Dustin Deus Date: Sun, 28 Jan 2018 23:06:49 +0100 Subject: [PATCH] check err --- commands/githook/githook.go | 4 ++-- main.go | 27 ++++++++++++++++++--------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/commands/githook/githook.go b/commands/githook/githook.go index 6c0251f..f843cf4 100644 --- a/commands/githook/githook.go +++ b/commands/githook/githook.go @@ -89,10 +89,10 @@ func (g *Githook) Install() error { } if utils.Exists(hookRepoPath) { - logy.Debugf("create symlink old: %s, new: %s", hookGitPath, hookRepoPath) + logy.Debugf("create symlink old: '%s', new: '%s'", hookGitPath, hookRepoPath) err := os.Link(hookRepoPath, hookGitPath) if err != nil { - logy.WithError(err).Errorf("could not link hook %s", h) + logy.WithError(err).Errorf("could not link hook '%s'", h) return err } logy.Infof("hook '%s' installed", h) diff --git a/main.go b/main.go index 363e73d..5714250 100644 --- a/main.go +++ b/main.go @@ -46,6 +46,7 @@ var ( }, }, } + hookCLIIcon = "✔ " ) func init() { @@ -53,6 +54,7 @@ func init() { cfg = config.ParseConfig(configName) // Windows compatible symbols + // @todo check terminal encoding if runtime.GOOS == "windows" { core.ErrorIcon = "X" core.HelpIcon = "????" @@ -60,6 +62,7 @@ func init() { core.SelectFocusIcon = ">" core.MarkedOptionIcon = "[x]" core.UnmarkedOptionIcon = "[ ]" + hookCLIIcon = "" } } @@ -90,24 +93,30 @@ func interactiveCliMode() { template.SetConfigName(surveyFilename), template.WithGitDir(cd), ) - command.StartCommandSurvey() - err := command.Run() + err := command.StartCommandSurvey() if err != nil { logy.WithError(err) - } else { - fmt.Println() - command.TaskTracker.PrintSummary(os.Stdout) - fmt.Printf("\nCommand executed!") + return } + err = command.Run() + if err != nil { + logy.WithError(err) + } + fmt.Println() + command.TaskTracker.PrintSummary(os.Stdout) + fmt.Printf("\n%sSuccessfully executed '%s' command!", hookCLIIcon, taskType) case "Install Git Hooks": command := githook.New(githook.WithGitDir(cd)) - command.StartCommandSurvey() + err := command.StartCommandSurvey() + if err != nil { + logy.WithError(err) + return + } err = command.Run() if err != nil { logy.Errorf(err.Error()) - } else { - fmt.Printf("\nCommand executed!") } + fmt.Printf("\n%sSuccessfully executed '%s' command!", hookCLIIcon, taskType) case "Auto Update": updater.ConfirmAndSelfUpdate(repository, version) case "Version":