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 Bold(s string) string
- func BoldFmt() pretty.Formatter
- func Code(s string) string
- func Color(s string) termenv.Color
- func DeprecationWarning(message string) serpent.MiddlewareFunc
- 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 ExternalAuth(ctx context.Context, writer io.Writer, opts ExternalAuthOptions) error
- func Field(s string) string
- func Info(wtr io.Writer, header string, lines ...string)
- func Infof(wtr io.Writer, fmtStr string, args ...interface{})
- func Keyword(s string) string
- func MultiSelect(inv *serpent.Invocation, opts MultiSelectOptions) ([]string, error)
- func PeerDiagnostics(w io.Writer, d tailnet.PeerDiagnostics)
- func Placeholder(s string) string
- func Prompt(inv *serpent.Invocation, opts PromptOptions) (string, error)
- func ProvisionerJob(ctx context.Context, wr io.Writer, opts ProvisionerJobOptions) error
- func RichParameter(inv *serpent.Invocation, ...) (string, error)
- func RichSelect(inv *serpent.Invocation, richOptions RichSelectOptions) (*codersdk.TemplateVersionParameterOption, error)
- func Select(inv *serpent.Invocation, opts SelectOptions) (string, error)
- func SkipPromptOption() serpent.Option
- func Table() table.Writer
- func Timestamp(t time.Time) string
- 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
- func Wrap(s string) string
- type AgentOptions
- type ConnDiags
- type DataChangeFormat
- type ExternalAuthOptions
- type MultiSelectOptions
- type OutputFormat
- type OutputFormatter
- type PromptOptions
- type ProvisionerJobError
- type ProvisionerJobOptions
- type RichSelectOptions
- type SelectOptions
- type Styles
- type TableSeparator
- type WorkspaceFilter
- type WorkspaceResourcesOptions
Constants¶
const (ConfirmYes = "yes"ConfirmNo = "no")
const (ProvisioningStateQueued = "Queued"ProvisioningStateRunning = "Running")
Variables¶
var ErrCanceled =xerrors.New("canceled")
Functions¶
funcBold¶added inv2.2.0
Bold returns a formatter that renders text in boldif the terminal supports it.
funcBoldFmt¶added inv2.2.0
BoldFmt returns a formatter that renders text in boldif the terminal supports it.
funcDeprecationWarning¶added inv2.7.0
func DeprecationWarning(messagestring)serpent.MiddlewareFunc
funcDisplayTable¶
DisplayTable renders a table as a string. The input argument can be:
- a struct slice.
- an interface slice, where the first element is a struct,and all other elements are of the same type, or a TableSeparator.
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.
funcExternalAuth¶added inv2.2.1
funcMultiSelect¶
func MultiSelect(inv *serpent.Invocation, optsMultiSelectOptions) ([]string,error)
funcPeerDiagnostics¶added inv2.9.0
func PeerDiagnostics(wio.Writer, dtailnet.PeerDiagnostics)
funcPlaceholder¶added inv2.2.0
Placeholder formats a placeholder for display.
funcPrompt¶
func Prompt(inv *serpent.Invocation, optsPromptOptions) (string,error)
Prompt asks the user for input.
funcProvisionerJob¶
ProvisionerJob renders a provisioner job with interactive cancellation.
funcRichParameter¶
func RichParameter(inv *serpent.Invocation, templateVersionParametercodersdk.TemplateVersionParameter, defaultOverrides map[string]string) (string,error)
funcRichSelect¶
func RichSelect(inv *serpent.Invocation, richOptionsRichSelectOptions) (*codersdk.TemplateVersionParameterOption,error)
RichSelect displays a list of user options including name and description.
funcSelect¶
func Select(inv *serpent.Invocation, optsSelectOptions) (string,error)
Select displays a list of user options.
funcSkipPromptOption¶
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¶
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.WorkspaceAgentLog,io.Closer,error)Waitbool// If true, wait for the agent to be ready (startup script).DocsURLstring}
typeConnDiags¶added inv2.15.0
type ConnDiags struct {ConnInfoworkspacesdk.AgentConnectionInfoPingP2PboolDisableDirectboolLocalNetInfo *tailcfg.NetInfoLocalInterfaces *healthsdk.InterfacesReportAgentNetcheck *healthsdk.AgentNetcheckReportClientIPIsAWSboolAgentIPIsAWSboolVerboseboolTroubleshootingURLstring}
typeDataChangeFormat¶
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¶
func ChangeFormatterData(formatOutputFormat, change func(dataany) (any,error)) *DataChangeFormat
ChangeFormatterData allows manipulating the data passed to an outputformat.
func (*DataChangeFormat)AttachOptions¶
func (d *DataChangeFormat) AttachOptions(opts *serpent.OptionSet)
func (*DataChangeFormat)ID¶
func (d *DataChangeFormat) ID()string
typeExternalAuthOptions¶added inv2.2.1
typeMultiSelectOptions¶added inv2.13.0
typeOutputFormat¶
type OutputFormat interface {ID()stringAttachOptions(opts *serpent.OptionSet)Format(ctxcontext.Context, dataany) (string,error)}
funcTableFormat¶
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¶
func TextFormat()OutputFormat
TextFormat is a formatter that just outputs unstructured text.It uses fmt.Sprintf under the hood.
typeOutputFormatter¶
type OutputFormatter struct {// contains filtered or unexported fields}
funcNewOutputFormatter¶
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¶
func (f *OutputFormatter) AttachOptions(opts *serpent.OptionSet)
AttachOptions attaches the --output flag to the given command, and anyadditional flags required by the output formatters.
func (*OutputFormatter)Format¶
Format formats the given data using the format specified by the --outputflag. If the flag is not set, the default format is used.
func (*OutputFormatter)FormatID¶added inv2.20.0
func (f *OutputFormatter) FormatID()string
FormatID will return the ID of the format selected by `--output`.If no flag is present, it returns the 'default' formatter.
typePromptOptions¶
type PromptOptions struct {TextstringDefaultstring// When true, the input will be masked with asterisks.SecretboolIsConfirmboolValidate func(string)error}
PromptOptions supply a set of options to the prompt.
typeProvisionerJobError¶
type ProvisionerJobError struct {MessagestringCodecodersdk.JobErrorCode}
func (*ProvisionerJobError)Error¶
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¶
type RichSelectOptions struct {Options []codersdk.TemplateVersionParameterOptionDefaultstringSizeintHideSearchbool}
typeSelectOptions¶
typeStyles¶
type Styles struct {Code,DateTimeStamp,Error,Field,Hyperlink,Keyword,Placeholder,Prompt,FocusedPrompt,Fuchsia,Warn,Wrappretty.Style}
var DefaultStylesStyles
DefaultStyles compose visual elements of the UI.
typeTableSeparator¶added inv2.13.0
type TableSeparator struct{}
This type can be supplied as part of a slice to DisplayTableor to a `TableFormat` `Format` call to render a separator.Leading separators are not supported and trailing separatorsare ignored by the table formatter.e.g. `[]any{someRow, TableSeparator, someRow}`
typeWorkspaceFilter¶added inv2.4.0
type WorkspaceFilter struct {// contains filtered or unexported fields}
WorkspaceFilter wraps codersdk.WorkspaceFilterand allows easy integration to a CLI command.Example usage:
func (r *RootCmd) MyCmd() *serpent.Command { var ( filter cliui.WorkspaceFilter ... ) cmd := &serpent.Command{ ... } filter.AttachOptions(&cmd.Options) ... return cmd}
The above will add the following flags to the command:--all--search
func (*WorkspaceFilter)AttachOptions¶added inv2.4.0
func (w *WorkspaceFilter) AttachOptions(opts *serpent.OptionSet)
func (*WorkspaceFilter)Filter¶added inv2.4.0
func (w *WorkspaceFilter) Filter()codersdk.WorkspaceFilter