cliui
packageThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
Documentation¶
Index¶
- Constants
- Variables
- func Agent(ctx context.Context, writer io.Writer, agentID uuid.UUID, opts AgentOptions) error
- func DisplayTable(out any, sort string, filterColumns []string) (string, error)
- func Error(wtr io.Writer, header string, lines ...string)
- func Errorf(wtr io.Writer, fmtStr string, args ...interface{})
- func GitAuth(ctx context.Context, writer io.Writer, opts GitAuthOptions) error
- func Info(wtr io.Writer, header string, lines ...string)
- func Infof(wtr io.Writer, fmtStr string, args ...interface{})
- func MultiSelect(inv *clibase.Invocation, items []string) ([]string, error)
- func Prompt(inv *clibase.Invocation, opts PromptOptions) (string, error)
- func ProvisionerJob(ctx context.Context, writer io.Writer, opts ProvisionerJobOptions) error
- func RichParameter(inv *clibase.Invocation, ...) (string, error)
- func RichSelect(inv *clibase.Invocation, richOptions RichSelectOptions) (*codersdk.TemplateVersionParameterOption, error)
- func Select(inv *clibase.Invocation, opts SelectOptions) (string, error)
- func SkipPromptOption() clibase.Option
- func Table() table.Writer
- func ValidateNotEmpty(s string) error
- func Warn(wtr io.Writer, header string, lines ...string)
- func Warnf(wtr io.Writer, fmtStr string, args ...interface{})
- func WorkspaceBuild(ctx context.Context, writer io.Writer, client *codersdk.Client, ...) error
- func WorkspaceResources(writer io.Writer, resources []codersdk.WorkspaceResource, ...) error
- type AgentOptions
- type DataChangeFormat
- type GitAuthOptions
- type OutputFormat
- type OutputFormatter
- type PromptOptions
- type ProvisionerJobError
- type ProvisionerJobOptions
- type RichSelectOptions
- type SelectOptions
- type Styles
- type WorkspaceResourcesOptions
Constants¶
const (ConfirmYes = "yes"ConfirmNo = "no")
Variables¶
var Canceled =xerrors.New("canceled")
Functions¶
funcDisplayTable¶added inv0.8.6
DisplayTable renders a table as a string. The input argument must be a sliceof structs. At least one field in the struct must have a `table:""` tagcontaining the name of the column in the outputted table.
If `sort` is not specified, the field with the `table:"$NAME,default_sort"`tag will be used to sort. An error will be returned if no field has this tag.
Nested structs are processed if the field has the `table:"$NAME,recursive"`tag and their fields will be named as `$PARENT_NAME $NAME`. If the tag ismalformed or a field is marked as recursive but does not contain a struct ora pointer to a struct, this function will return an error (even with an emptyinput slice).
If sort is empty, the input order will be used. If filterColumns is empty ornil, all available columns are included.
funcMultiSelect¶added inv0.20.0
func MultiSelect(inv *clibase.Invocation, items []string) ([]string,error)
funcPrompt¶
func Prompt(inv *clibase.Invocation, optsPromptOptions) (string,error)
Prompt asks the user for input.
funcProvisionerJob¶
ProvisionerJob renders a provisioner job with interactive cancellation.
funcRichParameter¶added inv0.15.2
func RichParameter(inv *clibase.Invocation, templateVersionParametercodersdk.TemplateVersionParameter) (string,error)
funcRichSelect¶added inv0.15.3
func RichSelect(inv *clibase.Invocation, richOptionsRichSelectOptions) (*codersdk.TemplateVersionParameterOption,error)
RichSelect displays a list of user options including name and description.
funcSelect¶
func Select(inv *clibase.Invocation, optsSelectOptions) (string,error)
Select displays a list of user options.
funcSkipPromptOption¶added inv0.21.0
SkipPromptOption adds a "--yes/-y" flag to the cmd that can be used to skipprompts.
funcValidateNotEmpty¶
ValidateNotEmpty is a helper function to disallow empty inputs!
funcWorkspaceBuild¶
funcWorkspaceResources¶added inv0.4.1
func WorkspaceResources(writerio.Writer, resources []codersdk.WorkspaceResource, optionsWorkspaceResourcesOptions)error
WorkspaceResources displays the connection status and tree-view of provided resources.┌────────────────────────────────────────────────────────────────────────────┐│ RESOURCE STATUS ACCESS │├────────────────────────────────────────────────────────────────────────────┤│ google_compute_disk.root │├────────────────────────────────────────────────────────────────────────────┤│ google_compute_instance.dev ││ └─ dev (linux, amd64) ⦾ connecting [10s] coder ssh dev.dev │├────────────────────────────────────────────────────────────────────────────┤│ kubernetes_pod.dev ││ ├─ go (linux, amd64) ⦿ connected coder ssh dev.go ││ └─ postgres (linux, amd64) ⦾ disconnected [4s] coder ssh dev.postgres │└────────────────────────────────────────────────────────────────────────────┘
Types¶
typeAgentOptions¶
type AgentOptions struct {FetchIntervaltime.DurationFetch func(ctxcontext.Context, agentIDuuid.UUID) (codersdk.WorkspaceAgent,error)FetchLogs func(ctxcontext.Context, agentIDuuid.UUID, afterint64, followbool) (<-chan []codersdk.WorkspaceAgentStartupLog,io.Closer,error)Waitbool// If true, wait for the agent to be ready (startup script).}
typeDataChangeFormat¶added inv0.23.0
type DataChangeFormat struct {// contains filtered or unexported fields}
DataChangeFormat allows manipulating the data passed to an output format.This is because sometimes the data needs to be manipulated before it can bepassed to the output format.For example, you may want to pass something different to the text formatterthan what you pass to the json formatter.
funcChangeFormatterData¶added inv0.23.0
func ChangeFormatterData(formatOutputFormat, change func(dataany) (any,error)) *DataChangeFormat
ChangeFormatterData allows manipulating the data passed to an outputformat.
func (*DataChangeFormat)AttachOptions¶added inv0.23.0
func (d *DataChangeFormat) AttachOptions(opts *clibase.OptionSet)
func (*DataChangeFormat)ID¶added inv0.23.0
func (d *DataChangeFormat) ID()string
typeGitAuthOptions¶added inv0.18.0
typeOutputFormat¶added inv0.17.1
type OutputFormat interface {ID()stringAttachOptions(opts *clibase.OptionSet)Format(ctxcontext.Context, dataany) (string,error)}
funcTableFormat¶added inv0.17.1
func TableFormat(outany, defaultColumns []string)OutputFormat
TableFormat creates a table formatter for the given output type. The outputtype should be specified as an empty slice of the desired type.
E.g.: TableFormat([]MyType{}, []string{"foo", "bar"})
defaultColumns is optional and specifies the default columns to display. Ifnot specified, all columns are displayed by default.
funcTextFormat¶added inv0.22.0
func TextFormat()OutputFormat
TextFormat is a formatter that just outputs unstructured text.It uses fmt.Sprintf under the hood.
typeOutputFormatter¶added inv0.17.1
type OutputFormatter struct {// contains filtered or unexported fields}
funcNewOutputFormatter¶added inv0.17.1
func NewOutputFormatter(formats ...OutputFormat) *OutputFormatter
NewOutputFormatter creates a new OutputFormatter with the given formats. Thefirst format is the default format. At least two formats must be provided.
func (*OutputFormatter)AttachOptions¶added inv0.21.0
func (f *OutputFormatter) AttachOptions(opts *clibase.OptionSet)
AttachOptions attaches the --output flag to the given command, and anyadditional flags required by the output formatters.
typePromptOptions¶
type PromptOptions struct {TextstringDefaultstringSecretboolIsConfirmboolValidate func(string)error}
PromptOptions supply a set of options to the prompt.
typeProvisionerJobError¶added inv0.19.0
type ProvisionerJobError struct {MessagestringCodecodersdk.JobErrorCode}
func (*ProvisionerJobError)Error¶added inv0.19.0
func (err *ProvisionerJobError) Error()string
typeProvisionerJobOptions¶
type ProvisionerJobOptions struct {Fetch func() (codersdk.ProvisionerJob,error)Cancel func()errorLogs func() (<-chancodersdk.ProvisionerJobLog,io.Closer,error)FetchIntervaltime.Duration// Verbose determines whether debug and trace logs will be shown.Verbosebool// Silent determines whether log output will be shown unless there is an// error.Silentbool}
typeRichSelectOptions¶added inv0.15.3
type RichSelectOptions struct {Options []codersdk.TemplateVersionParameterOptionDefaultstringSizeintHideSearchbool}