Skip to content

Commit

Permalink
check err
Browse files Browse the repository at this point in the history
  • Loading branch information
StarpTech committed Jan 28, 2018
1 parent f1dccf9 commit ed2b527
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
4 changes: 2 additions & 2 deletions commands/githook/githook.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
27 changes: 18 additions & 9 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,23 @@ var (
},
},
}
hookCLIIcon = "✔ "
)

func init() {
logy.SetLevel(logy.InfoLevel)
cfg = config.ParseConfig(configName)

// Windows compatible symbols
// @todo check terminal encoding
if runtime.GOOS == "windows" {
core.ErrorIcon = "X"
core.HelpIcon = "????"
core.QuestionIcon = "?"
core.SelectFocusIcon = ">"
core.MarkedOptionIcon = "[x]"
core.UnmarkedOptionIcon = "[ ]"
hookCLIIcon = ""
}
}

Expand Down Expand Up @@ -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":
Expand Down

0 comments on commit ed2b527

Please sign in to comment.