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 NoOnlySpaces(v interface{}) error
- func NoUpperCase(v interface{}) error
- 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
- func NewObjectWriter(output io.Writer, outputFormat string, data interface{}) OutputWriter
- func NewOutputWriter(output io.Writer, outputFormat string, headers ...string) OutputWriterdeprecated
- func NewOutputWriterWithOptions(output io.Writer, outputFormat string, opts []OutputWriterOption, ...) OutputWriter
- type OutputWriterOption
- 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 NoOnlySpaces ¶ added in v0.90.0
func NoOnlySpaces(v interface{}) error
NoOnlySpaces checks if a given input string contains only empty spaces and returns an error if it does. This function does not panic if the input value is not a string.
func NoUpperCase ¶ added in v0.90.0
func NoUpperCase(v interface{}) error
NoUpperCase checks if a given input string contains uppercase characters and returns an error if it does. This function does not panic if the input value is not a string.
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
deprecated
func NewOutputWriter(output io.Writer, outputFormat string, headers ...string) OutputWriter
NewOutputWriter gets a new instance of our output writer.
Deprecated: NewOutputWriter is being deprecated in favor of NewOutputWriterWithOptions Until it is removed, it will retain the existing behavior of converting incoming row values to their golang string representation for backward compatibility reasons
func NewOutputWriterWithOptions ¶ added in v1.1.0
func NewOutputWriterWithOptions(output io.Writer, outputFormat string, opts []OutputWriterOption, headers ...string) OutputWriter
NewOutputWriterWithOptions gets a new instance of our output writer with some customization options.
type OutputWriterOption ¶ added in v1.1.0
type OutputWriterOption func(*outputwriter)
OutputWriterOption is an option for outputwriter
func WithAutoStringify ¶ added in v1.1.0
func WithAutoStringify() OutputWriterOption
WithAutoStringify configures the output writer to automatically convert row fields to their golang string representations. It is used to maintain backward compatibility with old rendering behavior, and should be _avoided_ if that need does not apply.
type OutputWriterSpinner ¶
type OutputWriterSpinner interface {
OutputWriter
RenderWithSpinner()
StopSpinner()
}
OutputWriterSpinner is OutputWriter augmented with a spinner.
func NewOutputWriterSpinnerWithOptions ¶ added in v1.1.0
func NewOutputWriterSpinnerWithOptions(output io.Writer, outputFormat, spinnerText string, startSpinner bool, opts []OutputWriterOption, headers ...string) (OutputWriterSpinner, error)
NewOutputWriterSpinnerWithOptions returns implementation of OutputWriterSpinner.
func NewOutputWriterWithSpinner
deprecated
func NewOutputWriterWithSpinner(output io.Writer, outputFormat, spinnerText string, startSpinner bool, headers ...string) (OutputWriterSpinner, error)
NewOutputWriterWithSpinner returns implementation of OutputWriterSpinner.
Deprecated: NewOutputWriterWithSpinner is being deprecated in favor of NewOutputWriterspinnerWithOptions. Until it is removed, it will retain the existing behavior of converting incoming row values to their golang string representation for backward compatibility reasons
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.
func WithValidator ¶ added in v0.90.0
WithValidator specifies a validator to use while prompting the user
type PromptOptions ¶
type PromptOptions struct {
// Standard in/out/error
Stdio terminal.Stdio
Icons survey.IconSet
// Validators on user inputs
Validators []survey.Validator
}
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.