Documentation
¶
Index ¶
- Variables
- func Choose(question string, options []string) int
- func Confirm(question string, def bool) bool
- func EditString(question, current string) string
- func IsInteractive() bool
- func ReadPassphrase(prompt string, confirm bool) (string, error)
- func ReadPassphraseOptional(prompt string) (string, error)
- type PromptFunc
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func Choose ¶ added in v0.8.0
Choose presents a numbered menu and returns the 0-based index of the chosen option. Off a terminal, or on blank/invalid input, it returns 0 (the first option).
func Confirm ¶ added in v0.8.0
Confirm asks a yes/no question. Off a terminal, or on blank input, it returns def.
func EditString ¶ added in v0.8.0
EditString prompts for a replacement value, showing the current one. Off a terminal, or on blank input (just Enter), it keeps current.
func IsInteractive ¶ added in v0.8.0
func IsInteractive() bool
IsInteractive reports whether stdin is a terminal, so callers can choose an interactive flow versus a non-blocking default.
func ReadPassphrase ¶ added in v0.6.0
ReadPassphrase reads a passphrase from the controlling terminal without echo. When confirm is true it prompts a second time and verifies the two inputs match (used when setting a new passphrase).
func ReadPassphraseOptional ¶ added in v0.6.0
ReadPassphraseOptional reads a passphrase without echo. Empty input is returned as "" without error (caller treats as "skip"). Use for optional backup-passphrase prompts.
Types ¶
type PromptFunc ¶ added in v0.8.0
PromptFunc writes a prompt to stderr and reads one line of input. isTTY is false when stdin is not a terminal, so callers fall back to a default instead of blocking — important for the session-start hook and CI. Injectable so the interactive helpers can be tested without a real terminal, mirroring the crypto.DefaultPassphraseFunc seam.
var DefaultPrompt PromptFunc = readLine
DefaultPrompt is the production line reader.