Documentation
¶
Overview ¶
Package input provides interactive user input functionality for the terminal.
Index ¶
- func WithInput(ctx context.Context, i *Input) context.Context
- type ConfirmOptions
- type Input
- type LineOptions
- type PasswordOptions
- func (o *PasswordOptions) WithAllowEmpty(allow bool) *PasswordOptions
- func (o *PasswordOptions) WithConfirmPrompt(prompt string) *PasswordOptions
- func (o *PasswordOptions) WithConfirmation(require bool) *PasswordOptions
- func (o *PasswordOptions) WithMinLength(length int) *PasswordOptions
- func (o *PasswordOptions) WithPrompt(prompt string) *PasswordOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ConfirmOptions ¶
ConfirmOptions configures the behavior of Confirm prompts.
func NewConfirmOptions ¶
func NewConfirmOptions() *ConfirmOptions
NewConfirmOptions creates default ConfirmOptions.
func (*ConfirmOptions) WithDefault ¶
func (o *ConfirmOptions) WithDefault(def bool) *ConfirmOptions
WithDefault sets the default value.
func (*ConfirmOptions) WithPrompt ¶
func (o *ConfirmOptions) WithPrompt(prompt string) *ConfirmOptions
WithPrompt sets the prompt message.
func (*ConfirmOptions) WithSkipCondition ¶
func (o *ConfirmOptions) WithSkipCondition(skip bool) *ConfirmOptions
WithSkipCondition sets whether to skip the prompt.
type Input ¶
type Input struct {
// contains filtered or unexported fields
}
func FromContext ¶
FromContext retrieves the Input from the context. Returns nil if no Input is present.
func MustFromContext ¶
MustFromContext retrieves the Input from the context. Panics if no Input is present.
func (*Input) ReadPassword ¶
func (i *Input) ReadPassword(opts *PasswordOptions) (string, error)
type LineOptions ¶
type LineOptions struct {
Prompt string
Default string
AllowEmpty bool
Validator func(string) error
}
LineOptions configures the behavior of ReadLine prompts.
func NewLineOptions ¶
func NewLineOptions() *LineOptions
NewLineOptions creates default LineOptions.
func (*LineOptions) WithAllowEmpty ¶
func (o *LineOptions) WithAllowEmpty(allow bool) *LineOptions
WithAllowEmpty sets whether empty input is allowed.
func (*LineOptions) WithDefault ¶
func (o *LineOptions) WithDefault(def string) *LineOptions
WithDefault sets the default value.
func (*LineOptions) WithPrompt ¶
func (o *LineOptions) WithPrompt(prompt string) *LineOptions
WithPrompt sets the prompt message.
func (*LineOptions) WithValidator ¶
func (o *LineOptions) WithValidator(validator func(string) error) *LineOptions
WithValidator sets a validation function.
type PasswordOptions ¶
type PasswordOptions struct {
Prompt string
ConfirmPrompt string
RequireConfirmation bool
MinLength int
AllowEmpty bool
}
PasswordOptions configures the behavior of ReadPassword prompts.
func NewPasswordOptions ¶
func NewPasswordOptions() *PasswordOptions
NewPasswordOptions creates default PasswordOptions.
func (*PasswordOptions) WithAllowEmpty ¶
func (o *PasswordOptions) WithAllowEmpty(allow bool) *PasswordOptions
WithAllowEmpty sets whether empty passwords are allowed.
func (*PasswordOptions) WithConfirmPrompt ¶
func (o *PasswordOptions) WithConfirmPrompt(prompt string) *PasswordOptions
WithConfirmPrompt sets the confirmation prompt message.
func (*PasswordOptions) WithConfirmation ¶
func (o *PasswordOptions) WithConfirmation(require bool) *PasswordOptions
WithConfirmation enables/disables password confirmation.
func (*PasswordOptions) WithMinLength ¶
func (o *PasswordOptions) WithMinLength(length int) *PasswordOptions
WithMinLength sets the minimum password length.
func (*PasswordOptions) WithPrompt ¶
func (o *PasswordOptions) WithPrompt(prompt string) *PasswordOptions
WithPrompt sets the password prompt message.