INNER CODE UNIT · Go

main

manifoldco/promptui · _examples/custom_prompt/main.go:16

func main() {
	validate := func(input string) error {
		_, err := strconv.ParseFloat(input, 64)
		return err
	}

	templates := &promptui.PromptTemplates{
		Prompt:  "{{ . }} ",
		Valid:   "{{ . | green }} ",
		Invalid: "{{ . | red }} ",
		Success: "{{ . | bold }} ",
	}

	prompt := promptui.Prompt{
		Label:     "Spicy Level",
		Templates: templates,
		Validate:  validate,
	}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…