cli
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 ConfigureHTTPClient(ctx context.Context, clientCertFile, clientKeyFile string, ...) (context.Context, *http.Client, error)
- func ConfigureTraceProvider(ctx context.Context, logger slog.Logger, cfg *codersdk.DeploymentValues) (trace.TracerProvider, string, func(context.Context) error)
- func ConnectToPostgres(ctx context.Context, logger slog.Logger, driver string, dbURL string, ...) (*sql.DB, error)
- func DumpHandler(ctx context.Context, name string)
- func ExitError(code int, err error) error
- func FormatExamples(examples ...Example) string
- func IsLocalURL(ctx context.Context, u *url.URL) (bool, error)
- func IsLocalhost(host string) bool
- func ParseProvisionerTags(rawTags []string) (map[string]string, error)
- func PrintDeprecatedOptions() serpent.MiddlewareFunc
- func PrintLogo(inv *serpent.Invocation, daemonTitle string)
- func ReadAIProvidersFromEnv(environ []string) ([]codersdk.AIProviderConfig, error)
- func ReadExternalAuthProvidersFromEnv(environ []string) ([]codersdk.ExternalAuthConfig, error)
- func ServeHandler(ctx context.Context, logger slog.Logger, handler http.Handler, ...) (closeFunc func())
- func SlimUnsupported(w io.Writer, cmd string)
- func WithTestOnlyCoderConnectDialer(ctx context.Context, dialer coderConnectDialer) context.Context
- func WriteConfigMW(cfg *codersdk.DeploymentValues) serpent.MiddlewareFunc
- type ClaudeConfig
- type ClaudeConfigMCP
- type Example
- type HTTPServers
- type OrganizationContext
- type ParameterResolver
- func (pr *ParameterResolver) Resolve(inv *serpent.Invocation, action WorkspaceCLIAction, ...) ([]codersdk.WorkspaceBuildParameter, error)
- func (pr *ParameterResolver) WithEphemeralParameters(params []codersdk.WorkspaceBuildParameter) *ParameterResolver
- func (pr *ParameterResolver) WithLastBuildParameters(params []codersdk.WorkspaceBuildParameter) *ParameterResolver
- func (pr *ParameterResolver) WithPromptEphemeralParameters(promptEphemeralParameters bool) *ParameterResolver
- func (pr *ParameterResolver) WithPromptRichParameters(promptRichParameters bool) *ParameterResolver
- func (pr *ParameterResolver) WithRichParameters(params []codersdk.WorkspaceBuildParameter) *ParameterResolver
- func (pr *ParameterResolver) WithRichParametersDefaults(params []codersdk.WorkspaceBuildParameter) *ParameterResolver
- func (pr *ParameterResolver) WithRichParametersFile(fileMap map[string]string) *ParameterResolver
- func (pr *ParameterResolver) WithSourceWorkspaceParameters(params []codersdk.WorkspaceBuildParameter) *ParameterResolver
- type PrettyErrorFormatter
- type RootCmd
- func (r *RootCmd) AGPL() []*serpent.Command
- func (r *RootCmd) Command(subcommands []*serpent.Command) (*serpent.Command, error)
- func (r *RootCmd) CoreSubcommands() []*serpent.Command
- func (r *RootCmd) HeaderTransport(ctx context.Context, serverURL *url.URL) (*codersdk.HeaderTransport, error)
- func (r *RootCmd) InitClient(client *codersdk.Client) serpent.MiddlewareFunc
- func (r *RootCmd) Provisioners() *serpent.Command
- func (r *RootCmd) RunWithSubcommands(subcommands []*serpent.Command)
- func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd.API, io.Closer, error)) *serpent.Command
- func (r *RootCmd) TryInitClient(client *codersdk.Client) serpent.MiddlewareFunc
- func (r *RootCmd) Verbosef(inv *serpent.Invocation, fmtStr string, args ...interface{})
- type SpeedtestResult
- type SpeedtestResultInterval
- type StdioRwc
- type WorkspaceCLIAction
Constants¶
const (// Client ID forhttps://github.com/apps/coderGithubOAuth2DefaultProviderClientID = "Iv1.6a2b4b4aec4f4fe7"GithubOAuth2DefaultProviderAllowEveryone =trueGithubOAuth2DefaultProviderDeviceFlow =true)
Variables¶
var (Caret =pretty.Sprint(cliui.DefaultStyles.Prompt, "")// ErrSilent is a sentinel error that tells the command handler to just exit with a non-zero error, but not print// anything.ErrSilent =xerrors.New("silent error"))
var InterruptSignals = []os.Signal{os.Interrupt,}
InterruptSignals is the list of signals that are used for handlingimmediate shutdown behavior.
StopSignals is the list of signals that are used for handlingshutdown behavior.
StopSignals is the list of signals that are used for handlinggraceful shutdown behavior.
Functions¶
funcConnectToPostgres¶added inv2.2.0
func ConnectToPostgres(ctxcontext.Context, loggerslog.Logger, driverstring, dbURLstring, migrate func(db *sql.DB)error) (*sql.DB,error)
ConnectToPostgres takes in the migration command to run on the database onceit connects. To avoid running migrations, pass in `nil` or a no-op function.Regardless of the passed in migration function, if the database is not fullymigrated, an error will be returned. This can happen if the database is on afuture or past migration version.
If no error is returned, the database is fully migrated and up to date.
funcDumpHandler¶
DumpHandler provides a custom SIGQUIT and SIGTRAP handler that dumps thestacktrace of all goroutines to stderr and a well-known file in the homedirectory. This is useful for debugging deadlock issues that may occur inproduction in workspaces, since the default Go runtime will only dump tostderr (which is often difficult/impossible to read in a workspace).
SIGQUITs will still cause the program to exit (similarly to the default Goruntime behavior).
A SIGQUIT handler will not be registered if GOTRACEBACK=crash.
On Windows this immediately returns.
funcExitError¶added inv2.5.0
ExitError returns an error that will cause the CLI to exit with the givenexit code. If err is non-nil, it will be wrapped by the returned error.
funcFormatExamples¶added inv2.12.0
FormatExamples formats the examples as width wrapped bulletpointdescriptions with the command underneath.
funcIsLocalURL¶
isLocalURL returns true if the hostname of the provided URL appears toresolve to a loopback address.
funcIsLocalhost¶
IsLocalhost returns true if the host points to the local machine. Intended tobe called with `u.Hostname()`.
funcPrintDeprecatedOptions¶
func PrintDeprecatedOptions()serpent.MiddlewareFunc
printDeprecatedOptions loops through all command options, and printsa warning for usage of deprecated options.
funcReadAIProvidersFromEnv¶added inv2.23.0
func ReadAIProvidersFromEnv(environ []string) ([]codersdk.AIProviderConfig,error)
funcReadExternalAuthProvidersFromEnv¶added inv2.2.1
func ReadExternalAuthProvidersFromEnv(environ []string) ([]codersdk.ExternalAuthConfig,error)
ReadExternalAuthProvidersFromEnv is provided for compatibility purposes withthe viper CLI.
funcServeHandler¶
funcSlimUnsupported¶added inv2.1.5
funcWithTestOnlyCoderConnectDialer¶added inv2.22.0
funcWriteConfigMW¶
func WriteConfigMW(cfg *codersdk.DeploymentValues)serpent.MiddlewareFunc
writeConfigMW will prevent the main command from running if the write-configflag is set. Instead, it will marshal the command options to YAML and writethem to stdout.
Types¶
typeClaudeConfig¶added inv2.21.0
typeClaudeConfigMCP¶added inv2.21.0
typeExample¶added inv2.12.0
Example represents a standard example for command usage, to be usedwith FormatExamples.
typeHTTPServers¶
type HTTPServers struct {HTTPUrl *url.URLHTTPListenernet.Listener// TLSTLSUrl *url.URLTLSListenernet.ListenerTLSConfig *tls.Config}
funcConfigureHTTPServers¶
func ConfigureHTTPServers(loggerslog.Logger, inv *serpent.Invocation, cfg *codersdk.DeploymentValues) (_ *HTTPServers, errerror)
func (*HTTPServers)Close¶
func (s *HTTPServers) Close()
typeOrganizationContext¶added inv2.14.0
type OrganizationContext struct {// FlagSelect is the value passed in via the --org flagFlagSelectstring}
funcNewOrganizationContext¶added inv2.14.0
func NewOrganizationContext() *OrganizationContext
func (*OrganizationContext)AttachOptions¶added inv2.14.0
func (o *OrganizationContext) AttachOptions(cmd *serpent.Command)
func (*OrganizationContext)Selected¶added inv2.14.0
func (o *OrganizationContext) Selected(inv *serpent.Invocation, client *codersdk.Client) (codersdk.Organization,error)
func (*OrganizationContext)ValueSource¶added inv2.14.0
func (o *OrganizationContext) ValueSource(inv *serpent.Invocation) (string,serpent.ValueSource)
typeParameterResolver¶
type ParameterResolver struct {// contains filtered or unexported fields}
func (*ParameterResolver)Resolve¶
func (pr *ParameterResolver) Resolve(inv *serpent.Invocation, actionWorkspaceCLIAction, templateVersionParameters []codersdk.TemplateVersionParameter) ([]codersdk.WorkspaceBuildParameter,error)
func (*ParameterResolver)WithEphemeralParameters¶added inv2.17.0
func (pr *ParameterResolver) WithEphemeralParameters(params []codersdk.WorkspaceBuildParameter) *ParameterResolver
func (*ParameterResolver)WithLastBuildParameters¶
func (pr *ParameterResolver) WithLastBuildParameters(params []codersdk.WorkspaceBuildParameter) *ParameterResolver
func (*ParameterResolver)WithPromptEphemeralParameters¶added inv2.17.0
func (pr *ParameterResolver) WithPromptEphemeralParameters(promptEphemeralParametersbool) *ParameterResolver
func (*ParameterResolver)WithPromptRichParameters¶
func (pr *ParameterResolver) WithPromptRichParameters(promptRichParametersbool) *ParameterResolver
func (*ParameterResolver)WithRichParameters¶
func (pr *ParameterResolver) WithRichParameters(params []codersdk.WorkspaceBuildParameter) *ParameterResolver
func (*ParameterResolver)WithRichParametersDefaults¶added inv2.11.0
func (pr *ParameterResolver) WithRichParametersDefaults(params []codersdk.WorkspaceBuildParameter) *ParameterResolver
func (*ParameterResolver)WithRichParametersFile¶
func (pr *ParameterResolver) WithRichParametersFile(fileMap map[string]string) *ParameterResolver
func (*ParameterResolver)WithSourceWorkspaceParameters¶added inv2.4.0
func (pr *ParameterResolver) WithSourceWorkspaceParameters(params []codersdk.WorkspaceBuildParameter) *ParameterResolver
typePrettyErrorFormatter¶added inv2.10.0
type PrettyErrorFormatter struct {// contains filtered or unexported fields}
funcNewPrettyErrorFormatter¶added inv2.10.0
func NewPrettyErrorFormatter(wio.Writer, verbosebool) *PrettyErrorFormatter
NewPrettyErrorFormatter creates a new PrettyErrorFormatter.
func (*PrettyErrorFormatter)Format¶added inv2.10.0
func (p *PrettyErrorFormatter) Format(errerror)
Format formats the error to the writer in PrettyErrorFormatter.This error should be human readable.
typeRootCmd¶
type RootCmd struct {// contains filtered or unexported fields}
RootCmd contains parameters and helpers useful to all commands.
func (*RootCmd)CoreSubcommands¶added inv2.10.0
func (*RootCmd)HeaderTransport¶added inv2.5.0
func (r *RootCmd) HeaderTransport(ctxcontext.Context, serverURL *url.URL) (*codersdk.HeaderTransport,error)
HeaderTransport creates a new transport that executes `--header-command`if it is set to add headers for all outbound requests.
func (*RootCmd)InitClient¶
func (r *RootCmd) InitClient(client *codersdk.Client)serpent.MiddlewareFunc
InitClient authenticates the client with files from diskand injects header middlewares for telemetry, authentication,and version checks.
func (*RootCmd)Provisioners¶added inv2.19.0
func (*RootCmd)RunWithSubcommands¶added inv2.10.0
RunWithSubcommands runs the root command with the given subcommands.It is abstracted to enable the Enterprise code to add commands.
func (*RootCmd)TryInitClient¶added inv2.22.0
func (r *RootCmd) TryInitClient(client *codersdk.Client)serpent.MiddlewareFunc
TryInitClient is similar to InitClient but doesn't error when credentials are missing.This allows commands to run without requiring authentication, but still use auth if available.
typeSpeedtestResult¶added inv2.13.0
type SpeedtestResult struct {OverallSpeedtestResultInterval `json:"overall"`Intervals []SpeedtestResultInterval `json:"intervals"`}
typeSpeedtestResultInterval¶added inv2.13.0
typeWorkspaceCLIAction¶
type WorkspaceCLIActionint
const (WorkspaceCreateWorkspaceCLIAction =iotaWorkspaceStartWorkspaceUpdateWorkspaceRestart)
Source Files¶
- agent.go
- autoupdate.go
- completion.go
- configssh.go
- configssh_other.go
- connect.go
- create.go
- delete.go
- dotfiles.go
- dotfiles_other.go
- exp.go
- exp_errors.go
- exp_mcp.go
- exp_prompts.go
- exp_rpty.go
- exp_scaletest.go
- externalauth.go
- favorite.go
- gitaskpass.go
- gitssh.go
- help.go
- list.go
- login.go
- logout.go
- netcheck.go
- notifications.go
- open.go
- organization.go
- organizationmanage.go
- organizationmembers.go
- organizationroles.go
- organizationsettings.go
- parameter.go
- parameterresolver.go
- ping.go
- portforward.go
- provisionerjobs.go
- provisioners.go
- publickey.go
- remoteforward.go
- rename.go
- resetpassword.go
- restart.go
- root.go
- schedule.go
- server.go
- server_createadminuser.go
- server_regenerate_vapid_keypair.go
- show.go
- signal_unix.go
- speedtest.go
- ssh.go
- ssh_other.go
- start.go
- stat.go
- state.go
- stop.go
- support.go
- templatecreate.go
- templatedelete.go
- templateedit.go
- templateinit.go
- templatelist.go
- templatepull.go
- templatepush.go
- templates.go
- templateversionarchive.go
- templateversions.go
- tokens.go
- update.go
- usercreate.go
- userdelete.go
- usereditroles.go
- userlist.go
- users.go
- userstatus.go
- util.go
- version.go
- vpndaemon.go
- vpndaemon_other.go
- vscodessh.go
- whoami.go