diff --git a/buildPlugin.go b/buildPlugin.go index 07500d9..8d455a9 100644 --- a/buildPlugin.go +++ b/buildPlugin.go @@ -1,11 +1,6 @@ package fhelp import ( - "bufio" - "fmt" - "os" - "strings" - "go.wit.com/lib/gui/shell" "go.wit.com/log" ) @@ -29,7 +24,7 @@ func BuildPlugin(pname string) bool { log.Infof("To attempt to build the %s plugin, run:\n", pname) log.Info("forge --build go.wit.com/toolkits/gocui") log.Info("") - if !questionUser() { + if !QuestionUser("Would you like to run that now?") { return false } r := shell.RunRealtime([]string{"forge", "--build", "go.wit.com/toolkits/" + pname}) @@ -42,23 +37,3 @@ func BuildPlugin(pname string) bool { } return false } - -func questionUser() bool { - log.Info("Would you like to run that now?") - fmt.Fprintf(os.Stdout, "(y)es or (n)o ? ") - - scanner := bufio.NewScanner(os.Stdin) - for scanner.Scan() { - line := scanner.Text() - line = strings.TrimSpace(line) - line = strings.ToLower(line) - switch line { - case "y": - return true - case "n": - return false - default: - } - } - return false -} diff --git a/questionUser.go b/questionUser.go new file mode 100644 index 0000000..3bba4ae --- /dev/null +++ b/questionUser.go @@ -0,0 +1,30 @@ +package fhelp + +import ( + "bufio" + "fmt" + "os" + "strings" + + "go.wit.com/log" +) + +func QuestionUser(msg string) bool { + log.Info(msg) + fmt.Fprintf(os.Stdout, "(y)es or (n)o ? ") + + scanner := bufio.NewScanner(os.Stdin) + for scanner.Scan() { + line := scanner.Text() + line = strings.TrimSpace(line) + line = strings.ToLower(line) + switch line { + case "y": + return true + case "n": + return false + default: + } + } + return false +}