func()

in controller/ad/ad.go [104:129]


func (c controller) askForConfirmation(message *string) bool {

	if message == nil {
		return true
	}
	if len(*message) > 0 {
		fmt.Print(*message)
	}

	var response string
	_, err := fmt.Fscanln(c.reader, &response)
	if err != nil {
		//Exit if for some reason, we are not able to accept user input
		fmt.Printf("failed to accept value from user due to %s", err)
		os.Exit(1)
	}
	switch strings.ToLower(response) {
	case "y", "yes":
		return true
	case "n", "no":
		return false
	default:
		fmt.Printf("please type (y)es or (n)o and then press enter:")
		return c.askForConfirmation(mapper.StringToStringPtr(""))
	}
}