Debian Codegraph @

accessibility/accessibility.go

raw symbols SCIP
1 // Package accessibility provides accessible functions to capture user input.
2 //
3 // Deprecated: use [internal/accessibility] instead.
4 package accessibility
5
6 import (
7 "os"
8
9 "github.com/charmbracelet/huh/internal/accessibility"
10 )
11
12 // PromptInt prompts a user for an integer between a certain range.
13 //
14 // Given invalid input (non-integers, integers outside of the range), the user
15 // will continue to be reprompted until a valid input is given, ensuring that
16 // the return value is always valid.
17 //
18 // Deprecated: use [accessibility.PromptInt] instead.
19 func PromptInt(prompt string, low, high int) int {
20 return accessibility.PromptInt(os.Stdout, os.Stdin, prompt, low, high, nil)
21 }
22
23 // PromptBool prompts a user for a boolean value.
24 //
25 // Given invalid input (non-boolean), the user will continue to be reprompted
26 // until a valid input is given, ensuring that the return value is always valid.
27 //
28 // Deprecated: use [accessibility.PromptBool] instead.
29 func PromptBool() bool {
30 return accessibility.PromptBool(os.Stdout, os.Stdin, "Choose [y/N]: ", false)
31 }
32
33 // PromptString prompts a user for a string value and validates it against a
34 // validator function. It re-prompts the user until a valid input is given.
35 //
36 // Deprecated: use [accessibility.PromptString] instead.
37 func PromptString(prompt string, validator func(input string) error) string {
38 return accessibility.PromptString(os.Stdout, os.Stdin, prompt, "", validator)
39 }