prompter

package
v2.36.15 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 28, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Choose

func Choose(pr string, options []string) int

Choose given the choice return the option selected

func ChooseWithDefault

func ChooseWithDefault(pr string, defaultValue string, options []string) (string, error)

ChooseWithDefault given the choice return the option selected with a default

func Display added in v2.36.13

func Display(pr string)

Display prompt, no user input required

func ParseResults added in v2.34.0

func ParseResults(pinEntryOutput io.Reader) (output string, err error)

ParseResults parses the standard output of the pinentry command and determine the user input, or wheter the program yielded any error

func Password

func Password(pr string) string

Password prompt for password which is required

func RequestSecurityCode

func RequestSecurityCode(pattern string) string

RequestSecurityCode request a security code to be entered by the user

func SetOutputWriter added in v2.36.13

func SetOutputWriter(writer survey_terminal.FileWriter)

SetOutputWriter sets the output writer to use for all survey operations

func SetPrompter

func SetPrompter(prmpt Prompter)

SetPrompter configure an aternate prompter to the default one

func String

func String(pr string, defaultValue string) string

String prompt for string which is required

func StringRequired

func StringRequired(pr string) string

StringRequired prompt for string which is required

func ValidateAndSetPrompter added in v2.34.0

func ValidateAndSetPrompter(prmptCfg string) error

ValidateAndSetPrompter validates the user configuration and will create a concrete prompter based on this configuration

Types

type CliPrompter

type CliPrompter struct {
}

CliPrompter used to prompt for cli input

func NewCli

func NewCli() *CliPrompter

NewCli builds a new cli prompter

func (*CliPrompter) Choose

func (cli *CliPrompter) Choose(pr string, options []string) int

Choose given the choice return the option selected

func (*CliPrompter) ChooseWithDefault

func (cli *CliPrompter) ChooseWithDefault(pr string, defaultValue string, options []string) (string, error)

ChooseWithDefault given the choice return the option selected with a default

func (*CliPrompter) Display added in v2.36.13

func (cli *CliPrompter) Display(pr string)

func (*CliPrompter) Password

func (cli *CliPrompter) Password(pr string) string

Password prompt for password which is required

func (*CliPrompter) RequestSecurityCode

func (cli *CliPrompter) RequestSecurityCode(pattern string) string

RequestSecurityCode request a security code to be entered by the user

func (*CliPrompter) String

func (cli *CliPrompter) String(pr string, defaultValue string) string

String prompt for string with a default

func (*CliPrompter) StringRequired

func (cli *CliPrompter) StringRequired(pr string) string

StringRequired prompt for string which is required

type PinentryPrompter added in v2.34.0

type PinentryPrompter struct {
	Runner          PinentryRunner
	DefaultPrompter Prompter
}

PinentryPrompter is a concrete implementation of the Prompter interface. It uses the default Cli under the hood, except for RequestSecurityCode, where it uses any _pinentry_ binary to capture the security code. Its purpose is mainly to capture the TOTP code outside of the TTY, and thus making it possible to use TOTP with the credential process. https://github.com/Versent/saml2aws#using-saml2aws-as-credential-process

func NewPinentryPrompter added in v2.34.0

func NewPinentryPrompter(bin string) *PinentryPrompter

NewPinentryPrompter is a factory for PinentryPrompter

func (*PinentryPrompter) Choose added in v2.34.0

func (p *PinentryPrompter) Choose(pr string, options []string) int

Choose is running the default CLI Choose

func (*PinentryPrompter) ChooseWithDefault added in v2.34.0

func (p *PinentryPrompter) ChooseWithDefault(prompt string, def string, choices []string) (string, error)

ChooseWithDefault is running the default CLI ChooseWithDefault

func (*PinentryPrompter) Display added in v2.36.13

func (p *PinentryPrompter) Display(pr string)

Display is runniner the default Cli Display

func (*PinentryPrompter) Password added in v2.34.0

func (p *PinentryPrompter) Password(pr string) string

Password is runniner the default Cli Password

func (*PinentryPrompter) RequestSecurityCode added in v2.34.0

func (p *PinentryPrompter) RequestSecurityCode(pattern string) (output string)

RequestSecurityCode for PinentryPrompter is creating a query for pinentry and sends it to the pinentry bin.

func (*PinentryPrompter) String added in v2.34.0

func (p *PinentryPrompter) String(pr string, defaultValue string) string

String is runniner the default Cli String

func (*PinentryPrompter) StringRequired added in v2.34.0

func (p *PinentryPrompter) StringRequired(pr string) string

StringRequired is runniner the default Cli StringRequired

type PinentryRunner added in v2.34.0

type PinentryRunner interface {
	Run(string) (string, error)
}

PinentryRunner is the interface for pinentry to run itself

type Prompter

type Prompter interface {
	RequestSecurityCode(string) string
	ChooseWithDefault(string, string, []string) (string, error)
	Choose(string, []string) int
	StringRequired(string) string
	String(string, string) string
	Password(string) string
	Display(string)
}

Prompter handles prompting user for input

var ActivePrompter Prompter = NewCli()

ActivePrompter is by default the survey cli prompter

type RealPinentryRunner added in v2.34.0

type RealPinentryRunner struct {
	PinentryBin string
}

RealPinentryRunner is the concrete implementation of PinentryRunner

func NewRealPinentryRunner added in v2.34.0

func NewRealPinentryRunner(bin string) *RealPinentryRunner

NewRealPinentryRunner is a factory for RealPinentryRunner

func (*RealPinentryRunner) Run added in v2.34.0

func (r *RealPinentryRunner) Run(command string) (output string, err error)

Run wraps a pinentry run. It sends the query to pinentry via stdin and reads its stdout to determine the user PIN. Pinentry uses an Assuan protocol

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL