shared/cmd/ask.go
func AskString(question string, defaultAnswer string, validate func(string) error) string {
	for {
		answer := askQuestion(question, defaultAnswer)

		if validate != nil {
			error := validate(answer)
			if error != nil {
				fmt.Fprintf(os.Stderr, "Invalid input: %s\n\n", error)
				continue
			}

			return answer
		}

		if len(answer) != 0 {
			return answer
		}

		invalidInput()
	}
}
func AskString(question string, defaultAnswer string, validate func(string) error) string {
	for {
		answer := askQuestion(question, defaultAnswer)

		if validate != nil {
			error := validate(answer)
			if error != nil {
				fmt.Fprintf(os.Stderr, "Invalid input: %s\n\n", error)
				continue
			}

			return answer
		}

		if len(answer) != 0 {
			return answer
		}

		invalidInput()
	}
}
// AskString asks the user to enter a string, which optionally
// conforms to a validation function.