Documentation
¶
Overview ¶
internal/prompt/prompt.go
Index ¶
- func Confirm(prompt string, defaultValue bool) (bool, error)
- func EditInEditor(text string) (string, error)
- func Input(prompt, defaultValue string) (string, error)
- func InputWithSkip(title, description, defaultValue string) (string, bool, error)
- func IsInteractive() bool
- func Select(prompt string, options []string, defaultIndex int) (int, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Confirm ¶
Confirm prompts the user for a yes/no confirmation. Returns the defaultValue if not in an interactive terminal.
func EditInEditor ¶
EditInEditor opens the given text in the user's preferred editor and returns the edited content. Uses $VISUAL, then $EDITOR, then falls back to "vi". If not in an interactive terminal, returns the original text without editing.
func Input ¶
Input prompts the user for a single line of input with a default value. If the user enters nothing (just presses Enter), the default is returned. If not in an interactive terminal, the default is returned without prompting.
func InputWithSkip ¶ added in v0.6.0
InputWithSkip prompts the user for a single line of input with a default value, allowing the user to skip by pressing ESC or Ctrl+C. Returns (value, skipped, error).
When the user presses ESC or Ctrl+C, skipped is true and err is nil.
If not in an interactive terminal, the default is returned without prompting.
func IsInteractive ¶
func IsInteractive() bool
IsInteractive returns true if both stdin and stdout are connected to a terminal. This ensures prompts that require user input (like huh) won't hang when stdin is piped. Respects GH_FORCE_TTY, NO_COLOR, CLICOLOR, and CLICOLOR_FORCE environment variables for consistency with the gh CLI.
Types ¶
This section is empty.