Created
July 18, 2019 17:35
-
-
Save ducmeit1/ac50f6e56508513e9a2fda4a9121f448 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package common | |
import ( | |
"github.com/manifoldco/promptui" | |
"strconv" | |
) | |
func PromptString(name string) (string, error) { | |
prompt := promptui.Prompt{ | |
Label: name, | |
Validate: ValidateEmptyInput, | |
} | |
return prompt.Run() | |
} | |
func PromptInteger(name string) (int64, error) { | |
prompt := promptui.Prompt{ | |
Label: name, | |
Validate: ValidateIntegerNumberInput, | |
} | |
promptResult, err := prompt.Run() | |
if err != nil { | |
return 0, err | |
} | |
parseInt, _ := strconv.ParseInt(promptResult, 0, 64) | |
return parseInt, nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment