Documentation ¶
Overview ¶
Package component defines components that can be made use of in plugins.
Index ¶
- func Ask(q *QuestionConfig, response interface{}) error
- func AskForConfirmation(message string) error
- func BeginsWith(s, prefix string) bool
- func Bold(s string) string
- func IsTTYEnabled() bool
- func NewAurora() auroraPackage.Aurora
- func Prompt(p *PromptConfig, response interface{}, opts ...PromptOpt) error
- func ReadInput(filePath string) ([]byte, error)
- func Rpad(s string, padding int) string
- func Select(p *SelectConfig, response interface{}) error
- func TrimRightSpace(s string) string
- func Underline(s string) string
- type OutputType
- type OutputWriter
- type OutputWriterSpinner
- type PromptConfig
- type PromptOpt
- type PromptOptions
- type QuestionConfig
- type SelectConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Ask ¶
func Ask(q *QuestionConfig, response interface{}) error
Ask asks a questions and lets the user select an option.
func AskForConfirmation ¶
AskForConfirmation is used to prompt the user to confirm or deny a choice
func BeginsWith ¶
func IsTTYEnabled ¶
func IsTTYEnabled() bool
func NewAurora ¶
func NewAurora() auroraPackage.Aurora
func Prompt ¶
func Prompt(p *PromptConfig, response interface{}, opts ...PromptOpt) error
Prompt for input, reads input value, without trimming any characters (may include leading/tailing spaces)
func Rpad ¶
Rpad adds padding to the right of a string. from https://github.com/spf13/cobra/blob/993cc5372a05240dfd59e3ba952748b36b2cd117/cobra.go#L29
func TrimRightSpace ¶
Types ¶
type OutputType ¶
type OutputType string
OutputType defines the format of the output desired.
const ( // TableOutputType specifies output should be in table format. TableOutputType OutputType = "table" // YAMLOutputType specifies output should be in yaml format. YAMLOutputType OutputType = "yaml" // JSONOutputType specifies output should be in json format. JSONOutputType OutputType = "json" // ListTableOutputType specified output should be in a list table format. ListTableOutputType OutputType = "listtable" )
type OutputWriter ¶
type OutputWriter interface { SetKeys(headerKeys ...string) AddRow(items ...interface{}) Render() }
OutputWriter is an interface for something that can write output.
func NewObjectWriter ¶
func NewObjectWriter(output io.Writer, outputFormat string, data interface{}) OutputWriter
NewObjectWriter gets a new instance of our output writer.
func NewOutputWriter ¶
func NewOutputWriter(output io.Writer, outputFormat string, headers ...string) OutputWriter
NewOutputWriter gets a new instance of our output writer.
type OutputWriterSpinner ¶
type OutputWriterSpinner interface { OutputWriter RenderWithSpinner() StopSpinner() }
OutputWriterSpinner is OutputWriter augmented with a spinner.
func NewOutputWriterWithSpinner ¶
func NewOutputWriterWithSpinner(output io.Writer, outputFormat, spinnerText string, startSpinner bool, headers ...string) (OutputWriterSpinner, error)
NewOutputWriterWithSpinner returns implementation of OutputWriterSpinner.
type PromptConfig ¶
type PromptConfig struct { // Message to display to user. Message string // Options for user to choose from Options []string // Default option. Default string // Sensitive information. Sensitive bool // Help for the prompt. Help string }
PromptConfig is the configuration for a prompt.
func (*PromptConfig) Run ¶
func (p *PromptConfig) Run(response interface{}, opts ...PromptOpt) error
Run the prompt.
type PromptOpt ¶
type PromptOpt func(*PromptOptions) error
PromptOpt is an option for prompts
func WithStdio ¶
func WithStdio(in terminal.FileReader, out terminal.FileWriter, err io.Writer) PromptOpt
WithStdio specifies the standard input, output and error. By default, these are os.Stdin, os.Stdout, and os.Stderr.
type PromptOptions ¶
PromptOptions are options for prompting.
type QuestionConfig ¶
type QuestionConfig struct {
Message string
}
QuestionConfig stores config for prompting a CLI question.
func (*QuestionConfig) Run ¶
func (q *QuestionConfig) Run(response interface{}) error
Run asks a question.
type SelectConfig ¶
type SelectConfig struct { // Message to display to user. Message string // Default option. Default interface{} // Options to select frorm. Options []string // Sensitive information. Sensitive bool // Help for the prompt. Help string // PageSize defines how many options per page. PageSize int }
SelectConfig is the configuration for a selection.
func (*SelectConfig) Run ¶
func (p *SelectConfig) Run(response interface{}) error
Run the selection.