Documentation
¶
Index ¶
- func Confirm(prompt string) (bool, error)
- func Select(prompt string, choices []string) (int, error)
- func WithConfirm() func(*Input)
- func WithConfirmMsg(msg string) func(*Input)
- func WithMinLength(n int, msg string) func(*Input)
- func WithMismatchMsg(msg string) func(*Input)
- func WithRequired(required bool, msg string) func(*Input)
- type Formatter
- type Input
- type Result
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Confirm ¶
Confirm prints prompt to stderr and returns true only when the user types "y" or "Y". Any other input, including empty, returns false. This replaces huh.Confirm for simple yes/no prompts.
func Select ¶
Select displays a numbered list of choices on stderr and reads the user's selection from stdin. It does not use raw mode — the user sees their input. This replaces huh.Select for non-secret interactive menus.
path, err := prompter.Select("Multiple databases found", paths)
func WithConfirmMsg ¶
WithConfirmMsg sets a custom confirmation prompt message and enables confirmation.
func WithMinLength ¶
WithMinLength sets a minimum byte length for the entered value.
func WithMismatchMsg ¶
WithMismatchMsg sets the error message shown when confirmation does not match.
func WithRequired ¶
WithRequired marks the input as required (non-empty).
Types ¶
type Input ¶
type Input struct {
// contains filtered or unexported fields
}
Input represents a no-echo password/passphrase prompt.
func NewInput ¶
NewInput creates a new no-echo input builder with optional functional options.
input := NewInput("Master passphrase", WithConfirm(), WithRequired(true, "required"))
func (*Input) Run ¶
Run executes the no-echo prompt and returns a secure Result. Returns an error if stdin is not a terminal.
func (*Input) WithPromptFormatter ¶
WithPromptFormatter sets a custom prompt formatter.
type Result ¶
type Result struct {
// contains filtered or unexported fields
}
Result holds the secure password bytes with a zeroing method
func QuickWithConfirm ¶
QuickWithConfirm prompts for a password with confirmation.
func ReadSecret ¶
SecretInput reads a single secret value from the terminal with no echo. It is intentionally simpler than Input — no confirmation, no min-length — because it is used for storing secret values, not for passphrase entry.
Use this in the REPL's "set" command instead of reading the value as a command-line argument, which would expose it in terminal scrollback and shell history.
result, err := prompter.ReadSecret("Value for " + key)
if err != nil { ... }
defer result.Zero()
cmds.Set(key, string(result.Bytes()), keepcmd.SetOptions{})