diff --git a/cli/agent.go b/cli/agent.go index de24a2ac5c..aaef3805e6 100644 --- a/cli/agent.go +++ b/cli/agent.go @@ -34,7 +34,7 @@ import ( "github.com/coder/serpent" ) -func (r *RootCmd) workspaceAgent() *serpent.Cmd { +func (r *RootCmd) workspaceAgent() *serpent.Command { var ( auth string logDir string @@ -49,7 +49,7 @@ func (r *RootCmd) workspaceAgent() *serpent.Cmd { slogJSONPath string slogStackdriverPath string ) - cmd := &serpent.Cmd{ + cmd := &serpent.Command{ Use: "agent", Short: `Starts the Coder workspace agent.`, // This command isn't useful to manually execute. diff --git a/cli/autoupdate.go b/cli/autoupdate.go index 42a1b096df..5e3db8f2fe 100644 --- a/cli/autoupdate.go +++ b/cli/autoupdate.go @@ -11,9 +11,9 @@ import ( "github.com/coder/serpent" ) -func (r *RootCmd) autoupdate() *serpent.Cmd { +func (r *RootCmd) autoupdate() *serpent.Command { client := new(codersdk.Client) - cmd := &serpent.Cmd{ + cmd := &serpent.Command{ Annotations: workspaceCommand, Use: "autoupdate ", Short: "Toggle auto-update policy for a workspace", diff --git a/cli/clilog/clilog_test.go b/cli/clilog/clilog_test.go index 93c8225d04..31d1dcfab2 100644 --- a/cli/clilog/clilog_test.go +++ b/cli/clilog/clilog_test.go @@ -23,7 +23,7 @@ func TestBuilder(t *testing.T) { t.Run("NoConfiguration", func(t *testing.T) { t.Parallel() - cmd := &serpent.Cmd{ + cmd := &serpent.Command{ Use: "test", Handler: testHandler(t), } @@ -35,7 +35,7 @@ func TestBuilder(t *testing.T) { t.Parallel() tempFile := filepath.Join(t.TempDir(), "test.log") - cmd := &serpent.Cmd{ + cmd := &serpent.Command{ Use: "test", Handler: testHandler(t, clilog.WithHuman(tempFile), @@ -51,7 +51,7 @@ func TestBuilder(t *testing.T) { t.Parallel() tempFile := filepath.Join(t.TempDir(), "test.log") - cmd := &serpent.Cmd{ + cmd := &serpent.Command{ Use: "test", Handler: testHandler(t, clilog.WithHuman(tempFile), @@ -68,7 +68,7 @@ func TestBuilder(t *testing.T) { t.Parallel() tempFile := filepath.Join(t.TempDir(), "test.log") - cmd := &serpent.Cmd{ + cmd := &serpent.Command{ Use: "test", Handler: testHandler(t, clilog.WithHuman(tempFile)), } @@ -81,7 +81,7 @@ func TestBuilder(t *testing.T) { t.Parallel() tempFile := filepath.Join(t.TempDir(), "test.log") - cmd := &serpent.Cmd{ + cmd := &serpent.Command{ Use: "test", Handler: testHandler(t, clilog.WithJSON(tempFile), clilog.WithVerbose()), } @@ -107,7 +107,7 @@ func TestBuilder(t *testing.T) { // Use the default deployment values. dv := coderdtest.DeploymentValues(t) - cmd := &serpent.Cmd{ + cmd := &serpent.Command{ Use: "test", Handler: testHandler(t, clilog.FromDeploymentValues(dv)), } @@ -135,7 +135,7 @@ func TestBuilder(t *testing.T) { Enable: true, }, } - cmd := &serpent.Cmd{ + cmd := &serpent.Command{ Use: "test", Handler: testHandler(t, clilog.FromDeploymentValues(dv)), } @@ -150,7 +150,7 @@ func TestBuilder(t *testing.T) { t.Parallel() tempFile := filepath.Join(t.TempDir(), "doesnotexist", "test.log") - cmd := &serpent.Cmd{ + cmd := &serpent.Command{ Use: "test", Handler: func(inv *serpent.Invocation) error { logger, closeLog, err := clilog.New( diff --git a/cli/clitest/clitest.go b/cli/clitest/clitest.go index 47c635487d..fbc913e7b8 100644 --- a/cli/clitest/clitest.go +++ b/cli/clitest/clitest.go @@ -56,7 +56,7 @@ func (l *logWriter) Write(p []byte) (n int, err error) { } func NewWithCommand( - t testing.TB, cmd *serpent.Cmd, args ...string, + t testing.TB, cmd *serpent.Command, args ...string, ) (*serpent.Invocation, config.Root) { configDir := config.Root(t.TempDir()) // I really would like to fail test on error logs, but realistically, turning on by default diff --git a/cli/clitest/golden.go b/cli/clitest/golden.go index 7598e9842b..eec504e70b 100644 --- a/cli/clitest/golden.go +++ b/cli/clitest/golden.go @@ -48,7 +48,7 @@ func DefaultCases() []CommandHelpCase { // TestCommandHelp will test the help output of the given commands // using golden files. -func TestCommandHelp(t *testing.T, getRoot func(t *testing.T) *serpent.Cmd, cases []CommandHelpCase) { +func TestCommandHelp(t *testing.T, getRoot func(t *testing.T) *serpent.Command, cases []CommandHelpCase) { t.Parallel() rootClient, replacements := prepareTestData(t) @@ -148,7 +148,7 @@ func NormalizeGoldenFile(t *testing.T, byt []byte) []byte { return byt } -func extractVisibleCommandPaths(cmdPath []string, cmds []*serpent.Cmd) [][]string { +func extractVisibleCommandPaths(cmdPath []string, cmds []*serpent.Command) [][]string { var cmdPaths [][]string for _, c := range cmds { if c.Hidden { diff --git a/cli/clitest/handlers.go b/cli/clitest/handlers.go index f8f0f07688..20cb818032 100644 --- a/cli/clitest/handlers.go +++ b/cli/clitest/handlers.go @@ -11,8 +11,8 @@ import ( // non-root commands (like 'groups' or 'users'), a handler is required. // These handlers are likely just the 'help' handler, but this must be // explicitly set. -func HandlersOK(t *testing.T, cmd *serpent.Cmd) { - cmd.Walk(func(cmd *serpent.Cmd) { +func HandlersOK(t *testing.T, cmd *serpent.Command) { + cmd.Walk(func(cmd *serpent.Command) { if cmd.Handler == nil { // If you see this error, make the Handler a helper invoker. // Handler: func(inv *serpent.Invocation) error { diff --git a/cli/cliui/agent_test.go b/cli/cliui/agent_test.go index ca92ea71c7..8cfa481e83 100644 --- a/cli/cliui/agent_test.go +++ b/cli/cliui/agent_test.go @@ -382,7 +382,7 @@ func TestAgent(t *testing.T) { output := make(chan string, 100) // Buffered to avoid blocking, overflow is discarded. logs := make(chan []codersdk.WorkspaceAgentLog, 1) - cmd := &serpent.Cmd{ + cmd := &serpent.Command{ Handler: func(inv *serpent.Invocation) error { tc.opts.Fetch = func(_ context.Context, _ uuid.UUID) (codersdk.WorkspaceAgent, error) { t.Log("iter", len(tc.iter)) @@ -450,7 +450,7 @@ func TestAgent(t *testing.T) { t.Parallel() var fetchCalled uint64 - cmd := &serpent.Cmd{ + cmd := &serpent.Command{ Handler: func(inv *serpent.Invocation) error { buf := bytes.Buffer{} err := cliui.Agent(inv.Context(), &buf, uuid.Nil, cliui.AgentOptions{ diff --git a/cli/cliui/externalauth_test.go b/cli/cliui/externalauth_test.go index 2db6238493..1482aacc2d 100644 --- a/cli/cliui/externalauth_test.go +++ b/cli/cliui/externalauth_test.go @@ -22,7 +22,7 @@ func TestExternalAuth(t *testing.T) { defer cancel() ptty := ptytest.New(t) - cmd := &serpent.Cmd{ + cmd := &serpent.Command{ Handler: func(inv *serpent.Invocation) error { var fetched atomic.Bool return cliui.ExternalAuth(inv.Context(), inv.Stdout, cliui.ExternalAuthOptions{ diff --git a/cli/cliui/filter.go b/cli/cliui/filter.go index e6fb76109d..a496a8614e 100644 --- a/cli/cliui/filter.go +++ b/cli/cliui/filter.go @@ -11,12 +11,12 @@ var defaultQuery = "owner:me" // and allows easy integration to a CLI command. // Example usage: // -// func (r *RootCmd) MyCmd() *serpent.Cmd { +// func (r *RootCmd) MyCmd() *serpent.Command { // var ( // filter cliui.WorkspaceFilter // ... // ) -// cmd := &serpent.Cmd{ +// cmd := &serpent.Command{ // ... // } // filter.AttachOptions(&cmd.Options) diff --git a/cli/cliui/output_test.go b/cli/cliui/output_test.go index e49e414b3d..7e7912b5a6 100644 --- a/cli/cliui/output_test.go +++ b/cli/cliui/output_test.go @@ -101,7 +101,7 @@ func Test_OutputFormatter(t *testing.T) { }, ) - cmd := &serpent.Cmd{} + cmd := &serpent.Command{} f.AttachOptions(&cmd.Options) fs := cmd.Options.FlagSet() diff --git a/cli/cliui/prompt_test.go b/cli/cliui/prompt_test.go index 99a1bbc7f1..70f5fdf48a 100644 --- a/cli/cliui/prompt_test.go +++ b/cli/cliui/prompt_test.go @@ -147,7 +147,7 @@ func TestPrompt(t *testing.T) { func newPrompt(ptty *ptytest.PTY, opts cliui.PromptOptions, invOpt func(inv *serpent.Invocation)) (string, error) { value := "" - cmd := &serpent.Cmd{ + cmd := &serpent.Command{ Handler: func(inv *serpent.Invocation) error { var err error value, err = cliui.Prompt(inv, opts) @@ -210,7 +210,7 @@ func TestPasswordTerminalState(t *testing.T) { // nolint:unused func passwordHelper() { - cmd := &serpent.Cmd{ + cmd := &serpent.Command{ Handler: func(inv *serpent.Invocation) error { cliui.Prompt(inv, cliui.PromptOptions{ Text: "Password:", diff --git a/cli/cliui/provisionerjob_test.go b/cli/cliui/provisionerjob_test.go index e35aaa96e0..19241fc9b1 100644 --- a/cli/cliui/provisionerjob_test.go +++ b/cli/cliui/provisionerjob_test.go @@ -127,7 +127,7 @@ func newProvisionerJob(t *testing.T) provisionerJobTest { } jobLock := sync.Mutex{} logs := make(chan codersdk.ProvisionerJobLog, 1) - cmd := &serpent.Cmd{ + cmd := &serpent.Command{ Handler: func(inv *serpent.Invocation) error { return cliui.ProvisionerJob(inv.Context(), inv.Stdout, cliui.ProvisionerJobOptions{ FetchInterval: time.Millisecond, diff --git a/cli/cliui/select_test.go b/cli/cliui/select_test.go index fe26d71138..c399121adb 100644 --- a/cli/cliui/select_test.go +++ b/cli/cliui/select_test.go @@ -31,7 +31,7 @@ func TestSelect(t *testing.T) { func newSelect(ptty *ptytest.PTY, opts cliui.SelectOptions) (string, error) { value := "" - cmd := &serpent.Cmd{ + cmd := &serpent.Command{ Handler: func(inv *serpent.Invocation) error { var err error value, err = cliui.Select(inv, opts) @@ -72,7 +72,7 @@ func TestRichSelect(t *testing.T) { func newRichSelect(ptty *ptytest.PTY, opts cliui.RichSelectOptions) (string, error) { value := "" - cmd := &serpent.Cmd{ + cmd := &serpent.Command{ Handler: func(inv *serpent.Invocation) error { richOption, err := cliui.RichSelect(inv, opts) if err == nil { @@ -105,7 +105,7 @@ func TestMultiSelect(t *testing.T) { func newMultiSelect(ptty *ptytest.PTY, items []string) ([]string, error) { var values []string - cmd := &serpent.Cmd{ + cmd := &serpent.Command{ Handler: func(inv *serpent.Invocation) error { selectedItems, err := cliui.MultiSelect(inv, items) if err == nil { diff --git a/cli/configssh.go b/cli/configssh.go index d8b179dd90..87cfe88a64 100644 --- a/cli/configssh.go +++ b/cli/configssh.go @@ -215,7 +215,7 @@ func sshPrepareWorkspaceConfigs(ctx context.Context, client *codersdk.Client) (r } } -func (r *RootCmd) configSSH() *serpent.Cmd { +func (r *RootCmd) configSSH() *serpent.Command { var ( sshConfigFile string sshConfigOpts sshConfigOptions @@ -226,7 +226,7 @@ func (r *RootCmd) configSSH() *serpent.Cmd { coderCliPath string ) client := new(codersdk.Client) - cmd := &serpent.Cmd{ + cmd := &serpent.Command{ Annotations: workspaceCommand, Use: "config-ssh", Short: "Add an SSH Host entry for your workspaces \"ssh coder.workspace\"", diff --git a/cli/create.go b/cli/create.go index 126b77048d..4aff56992d 100644 --- a/cli/create.go +++ b/cli/create.go @@ -19,7 +19,7 @@ import ( "github.com/coder/serpent" ) -func (r *RootCmd) create() *serpent.Cmd { +func (r *RootCmd) create() *serpent.Command { var ( templateName string startAt string @@ -31,7 +31,7 @@ func (r *RootCmd) create() *serpent.Cmd { copyParametersFrom string ) client := new(codersdk.Client) - cmd := &serpent.Cmd{ + cmd := &serpent.Command{ Annotations: workspaceCommand, Use: "create [name]", Short: "Create a workspace", diff --git a/cli/delete.go b/cli/delete.go index 367cbc76f0..174205afe2 100644 --- a/cli/delete.go +++ b/cli/delete.go @@ -10,10 +10,10 @@ import ( ) // nolint -func (r *RootCmd) deleteWorkspace() *serpent.Cmd { +func (r *RootCmd) deleteWorkspace() *serpent.Command { var orphan bool client := new(codersdk.Client) - cmd := &serpent.Cmd{ + cmd := &serpent.Command{ Annotations: workspaceCommand, Use: "delete ", Short: "Delete a workspace", diff --git a/cli/dotfiles.go b/cli/dotfiles.go index bfb9e7ca72..3dd0b28479 100644 --- a/cli/dotfiles.go +++ b/cli/dotfiles.go @@ -19,12 +19,12 @@ import ( "github.com/coder/serpent" ) -func (r *RootCmd) dotfiles() *serpent.Cmd { +func (r *RootCmd) dotfiles() *serpent.Command { var symlinkDir string var gitbranch string var dotfilesRepoDir string - cmd := &serpent.Cmd{ + cmd := &serpent.Command{ Use: "dotfiles ", Middleware: serpent.RequireNArgs(1), Short: "Personalize your workspace by applying a canonical dotfiles repository", diff --git a/cli/errors.go b/cli/errors.go index 1a32b322e7..414474c3ae 100644 --- a/cli/errors.go +++ b/cli/errors.go @@ -13,9 +13,9 @@ import ( "github.com/coder/serpent" ) -func (RootCmd) errorExample() *serpent.Cmd { - errorCmd := func(use string, err error) *serpent.Cmd { - return &serpent.Cmd{ +func (RootCmd) errorExample() *serpent.Command { + errorCmd := func(use string, err error) *serpent.Command { + return &serpent.Command{ Use: use, Handler: func(inv *serpent.Invocation) error { return err @@ -52,7 +52,7 @@ func (RootCmd) errorExample() *serpent.Cmd { // Some flags var magicWord serpent.String - cmd := &serpent.Cmd{ + cmd := &serpent.Command{ Use: "example-error", Short: "Shows what different error messages look like", Long: "This command is pretty pointless, but without it testing errors is" + @@ -61,7 +61,7 @@ func (RootCmd) errorExample() *serpent.Cmd { Handler: func(inv *serpent.Invocation) error { return inv.Command.HelpHandler(inv) }, - Children: []*serpent.Cmd{ + Children: []*serpent.Command{ // Typical codersdk api error errorCmd("api", apiError), diff --git a/cli/exp.go b/cli/exp.go index 42a2e94f02..3d63057638 100644 --- a/cli/exp.go +++ b/cli/exp.go @@ -2,15 +2,15 @@ package cli import "github.com/coder/serpent" -func (r *RootCmd) expCmd() *serpent.Cmd { - cmd := &serpent.Cmd{ +func (r *RootCmd) expCmd() *serpent.Command { + cmd := &serpent.Command{ Use: "exp", Short: "Internal commands for testing and experimentation. These are prone to breaking changes with no notice.", Handler: func(i *serpent.Invocation) error { return i.Command.HelpHandler(i) }, Hidden: true, - Children: []*serpent.Cmd{ + Children: []*serpent.Command{ r.scaletestCmd(), r.errorExample(), }, diff --git a/cli/exp_scaletest.go b/cli/exp_scaletest.go index 78cc55a27f..e92c3b5eee 100644 --- a/cli/exp_scaletest.go +++ b/cli/exp_scaletest.go @@ -44,14 +44,14 @@ import ( const scaletestTracerName = "coder_scaletest" -func (r *RootCmd) scaletestCmd() *serpent.Cmd { - cmd := &serpent.Cmd{ +func (r *RootCmd) scaletestCmd() *serpent.Command { + cmd := &serpent.Command{ Use: "scaletest", Short: "Run a scale test against the Coder API", Handler: func(inv *serpent.Invocation) error { return inv.Command.HelpHandler(inv) }, - Children: []*serpent.Cmd{ + Children: []*serpent.Command{ r.scaletestCleanup(), r.scaletestDashboard(), r.scaletestCreateWorkspaces(), @@ -398,13 +398,13 @@ func (r *userCleanupRunner) Run(ctx context.Context, _ string, _ io.Writer) erro return nil } -func (r *RootCmd) scaletestCleanup() *serpent.Cmd { +func (r *RootCmd) scaletestCleanup() *serpent.Command { var template string cleanupStrategy := &scaletestStrategyFlags{cleanup: true} client := new(codersdk.Client) - cmd := &serpent.Cmd{ + cmd := &serpent.Command{ Use: "cleanup", Short: "Cleanup scaletest workspaces, then cleanup scaletest users.", Long: "The strategy flags will apply to each stage of the cleanup process.", @@ -521,7 +521,7 @@ func (r *RootCmd) scaletestCleanup() *serpent.Cmd { return cmd } -func (r *RootCmd) scaletestCreateWorkspaces() *serpent.Cmd { +func (r *RootCmd) scaletestCreateWorkspaces() *serpent.Command { var ( count int64 retry int64 @@ -558,7 +558,7 @@ func (r *RootCmd) scaletestCreateWorkspaces() *serpent.Cmd { client := new(codersdk.Client) - cmd := &serpent.Cmd{ + cmd := &serpent.Command{ Use: "create-workspaces", Short: "Creates many users, then creates a workspace for each user and waits for them finish building and fully come online. Optionally runs a command inside each workspace, and connects to the workspace over WireGuard.", Long: `It is recommended that all rate limits are disabled on the server before running this scaletest. This test generates many login events which will be rate limited against the (most likely single) IP.`, @@ -864,7 +864,7 @@ func (r *RootCmd) scaletestCreateWorkspaces() *serpent.Cmd { return cmd } -func (r *RootCmd) scaletestWorkspaceTraffic() *serpent.Cmd { +func (r *RootCmd) scaletestWorkspaceTraffic() *serpent.Command { var ( tickInterval time.Duration bytesPerTick int64 @@ -881,7 +881,7 @@ func (r *RootCmd) scaletestWorkspaceTraffic() *serpent.Cmd { prometheusFlags = &scaletestPrometheusFlags{} ) - cmd := &serpent.Cmd{ + cmd := &serpent.Command{ Use: "workspace-traffic", Short: "Generate traffic to scaletest workspaces through coderd", Middleware: serpent.Chain( @@ -1109,7 +1109,7 @@ func (r *RootCmd) scaletestWorkspaceTraffic() *serpent.Cmd { return cmd } -func (r *RootCmd) scaletestDashboard() *serpent.Cmd { +func (r *RootCmd) scaletestDashboard() *serpent.Command { var ( interval time.Duration jitter time.Duration @@ -1125,7 +1125,7 @@ func (r *RootCmd) scaletestDashboard() *serpent.Cmd { prometheusFlags = &scaletestPrometheusFlags{} ) - cmd := &serpent.Cmd{ + cmd := &serpent.Command{ Use: "dashboard", Short: "Generate traffic to the HTTP API to simulate use of the dashboard.", Middleware: serpent.Chain( diff --git a/cli/exp_scaletest_slim.go b/cli/exp_scaletest_slim.go index 901d968693..631a166f17 100644 --- a/cli/exp_scaletest_slim.go +++ b/cli/exp_scaletest_slim.go @@ -4,8 +4,8 @@ package cli import "github.com/coder/serpent" -func (r *RootCmd) scaletestCmd() *serpent.Cmd { - cmd := &serpent.Cmd{ +func (r *RootCmd) scaletestCmd() *serpent.Command { + cmd := &serpent.Command{ Use: "scaletest", Short: "Run a scale test against the Coder API", Handler: func(inv *serpent.Invocation) error { diff --git a/cli/externalauth.go b/cli/externalauth.go index 6035dfa538..a5123a3e23 100644 --- a/cli/externalauth.go +++ b/cli/externalauth.go @@ -12,23 +12,23 @@ import ( "github.com/coder/serpent" ) -func (r *RootCmd) externalAuth() *serpent.Cmd { - return &serpent.Cmd{ +func (r *RootCmd) externalAuth() *serpent.Command { + return &serpent.Command{ Use: "external-auth", Short: "Manage external authentication", Long: "Authenticate with external services inside of a workspace.", Handler: func(i *serpent.Invocation) error { return i.Command.HelpHandler(i) }, - Children: []*serpent.Cmd{ + Children: []*serpent.Command{ r.externalAuthAccessToken(), }, } } -func (r *RootCmd) externalAuthAccessToken() *serpent.Cmd { +func (r *RootCmd) externalAuthAccessToken() *serpent.Command { var extra string - return &serpent.Cmd{ + return &serpent.Command{ Use: "access-token ", Short: "Print auth for an external provider", Long: "Print an access-token for an external auth provider. " + diff --git a/cli/favorite.go b/cli/favorite.go index 234ab27084..efb731abb3 100644 --- a/cli/favorite.go +++ b/cli/favorite.go @@ -9,9 +9,9 @@ import ( "github.com/coder/serpent" ) -func (r *RootCmd) favorite() *serpent.Cmd { +func (r *RootCmd) favorite() *serpent.Command { client := new(codersdk.Client) - cmd := &serpent.Cmd{ + cmd := &serpent.Command{ Aliases: []string{"fav", "favou" + "rite"}, Annotations: workspaceCommand, Use: "favorite ", @@ -36,9 +36,9 @@ func (r *RootCmd) favorite() *serpent.Cmd { return cmd } -func (r *RootCmd) unfavorite() *serpent.Cmd { +func (r *RootCmd) unfavorite() *serpent.Command { client := new(codersdk.Client) - cmd := &serpent.Cmd{ + cmd := &serpent.Command{ Aliases: []string{"unfav", "unfavou" + "rite"}, Annotations: workspaceCommand, Use: "unfavorite ", diff --git a/cli/gitaskpass.go b/cli/gitaskpass.go index 2a913b4766..88d2d652dc 100644 --- a/cli/gitaskpass.go +++ b/cli/gitaskpass.go @@ -18,8 +18,8 @@ import ( // gitAskpass is used by the Coder agent to automatically authenticate // with Git providers based on a hostname. -func (r *RootCmd) gitAskpass() *serpent.Cmd { - return &serpent.Cmd{ +func (r *RootCmd) gitAskpass() *serpent.Command { + return &serpent.Command{ Use: "gitaskpass", Hidden: true, Handler: func(inv *serpent.Invocation) error { diff --git a/cli/gitssh.go b/cli/gitssh.go index ec57c790c6..f427e43812 100644 --- a/cli/gitssh.go +++ b/cli/gitssh.go @@ -18,8 +18,8 @@ import ( "github.com/coder/serpent" ) -func (r *RootCmd) gitssh() *serpent.Cmd { - cmd := &serpent.Cmd{ +func (r *RootCmd) gitssh() *serpent.Command { + cmd := &serpent.Command{ Use: "gitssh", Hidden: true, Short: `Wraps the "ssh" command and uses the coder gitssh key for authentication`, diff --git a/cli/help.go b/cli/help.go index f12cea9b05..0654eb7bd9 100644 --- a/cli/help.go +++ b/cli/help.go @@ -107,7 +107,7 @@ var usageTemplate = func() *template.Template { } return sb.String() }, - "formatSubcommand": func(cmd *serpent.Cmd) string { + "formatSubcommand": func(cmd *serpent.Command) string { // Minimize padding by finding the longest neighboring name. maxNameLength := len(cmd.Name()) if parent := cmd.Parent; parent != nil { @@ -189,12 +189,12 @@ var usageTemplate = func() *template.Template { s = wrapTTY(s) return s }, - "visibleChildren": func(cmd *serpent.Cmd) []*serpent.Cmd { - return filterSlice(cmd.Children, func(c *serpent.Cmd) bool { + "visibleChildren": func(cmd *serpent.Command) []*serpent.Command { + return filterSlice(cmd.Children, func(c *serpent.Command) bool { return !c.Hidden }) }, - "optionGroups": func(cmd *serpent.Cmd) []optionGroup { + "optionGroups": func(cmd *serpent.Command) []optionGroup { groups := []optionGroup{{ // Default group. Name: "", diff --git a/cli/list.go b/cli/list.go index b86256a6bb..05ae08bf15 100644 --- a/cli/list.go +++ b/cli/list.go @@ -70,7 +70,7 @@ func workspaceListRowFromWorkspace(now time.Time, workspace codersdk.Workspace) } } -func (r *RootCmd) list() *serpent.Cmd { +func (r *RootCmd) list() *serpent.Command { var ( filter cliui.WorkspaceFilter formatter = cliui.NewOutputFormatter( @@ -92,7 +92,7 @@ func (r *RootCmd) list() *serpent.Cmd { ) ) client := new(codersdk.Client) - cmd := &serpent.Cmd{ + cmd := &serpent.Command{ Annotations: workspaceCommand, Use: "list", Short: "List workspaces", diff --git a/cli/login.go b/cli/login.go index 4bd464e4fd..7539497853 100644 --- a/cli/login.go +++ b/cli/login.go @@ -125,7 +125,7 @@ func (r *RootCmd) loginWithPassword( return nil } -func (r *RootCmd) login() *serpent.Cmd { +func (r *RootCmd) login() *serpent.Command { const firstUserTrialEnv = "CODER_FIRST_USER_TRIAL" var ( @@ -135,7 +135,7 @@ func (r *RootCmd) login() *serpent.Cmd { trial bool useTokenForSession bool ) - cmd := &serpent.Cmd{ + cmd := &serpent.Command{ Use: "login []", Short: "Authenticate with Coder deployment", Middleware: serpent.RequireRangeArgs(0, 1), diff --git a/cli/logout.go b/cli/logout.go index f70d60aae7..290422f492 100644 --- a/cli/logout.go +++ b/cli/logout.go @@ -12,9 +12,9 @@ import ( "github.com/coder/serpent" ) -func (r *RootCmd) logout() *serpent.Cmd { +func (r *RootCmd) logout() *serpent.Command { client := new(codersdk.Client) - cmd := &serpent.Cmd{ + cmd := &serpent.Command{ Use: "logout", Short: "Unauthenticate your local session", Middleware: serpent.Chain( diff --git a/cli/netcheck.go b/cli/netcheck.go index a1f535eb35..9035870e3f 100644 --- a/cli/netcheck.go +++ b/cli/netcheck.go @@ -13,10 +13,10 @@ import ( "github.com/coder/serpent" ) -func (r *RootCmd) netcheck() *serpent.Cmd { +func (r *RootCmd) netcheck() *serpent.Command { client := new(codersdk.Client) - cmd := &serpent.Cmd{ + cmd := &serpent.Command{ Use: "netcheck", Short: "Print network debug information for DERP and STUN", Middleware: serpent.Chain( diff --git a/cli/open.go b/cli/open.go index 77fac7e1ce..80f4fdf4c6 100644 --- a/cli/open.go +++ b/cli/open.go @@ -17,14 +17,14 @@ import ( "github.com/coder/serpent" ) -func (r *RootCmd) open() *serpent.Cmd { - cmd := &serpent.Cmd{ +func (r *RootCmd) open() *serpent.Command { + cmd := &serpent.Command{ Use: "open", Short: "Open a workspace", Handler: func(inv *serpent.Invocation) error { return inv.Command.HelpHandler(inv) }, - Children: []*serpent.Cmd{ + Children: []*serpent.Command{ r.openVSCode(), }, } @@ -33,14 +33,14 @@ func (r *RootCmd) open() *serpent.Cmd { const vscodeDesktopName = "VS Code Desktop" -func (r *RootCmd) openVSCode() *serpent.Cmd { +func (r *RootCmd) openVSCode() *serpent.Command { var ( generateToken bool testOpenError bool ) client := new(codersdk.Client) - cmd := &serpent.Cmd{ + cmd := &serpent.Command{ Annotations: workspaceCommand, Use: "vscode []", Short: fmt.Sprintf("Open a workspace in %s", vscodeDesktopName), diff --git a/cli/organization.go b/cli/organization.go index 1f92ffd82f..a2942b0c64 100644 --- a/cli/organization.go +++ b/cli/organization.go @@ -16,8 +16,8 @@ import ( "github.com/coder/serpent" ) -func (r *RootCmd) organizations() *serpent.Cmd { - cmd := &serpent.Cmd{ +func (r *RootCmd) organizations() *serpent.Command { + cmd := &serpent.Command{ Annotations: workspaceCommand, Use: "organizations [subcommand]", Short: "Organization related commands", @@ -26,7 +26,7 @@ func (r *RootCmd) organizations() *serpent.Cmd { Handler: func(inv *serpent.Invocation) error { return inv.Command.HelpHandler(inv) }, - Children: []*serpent.Cmd{ + Children: []*serpent.Command{ r.currentOrganization(), r.switchOrganization(), r.createOrganization(), @@ -37,10 +37,10 @@ func (r *RootCmd) organizations() *serpent.Cmd { return cmd } -func (r *RootCmd) switchOrganization() *serpent.Cmd { +func (r *RootCmd) switchOrganization() *serpent.Command { client := new(codersdk.Client) - cmd := &serpent.Cmd{ + cmd := &serpent.Command{ Use: "set ", Short: "set the organization used by the CLI. Pass an empty string to reset to the default organization.", Long: "set the organization used by the CLI. Pass an empty string to reset to the default organization.\n" + formatExamples( @@ -206,7 +206,7 @@ func orgNames(orgs []codersdk.Organization) []string { return names } -func (r *RootCmd) currentOrganization() *serpent.Cmd { +func (r *RootCmd) currentOrganization() *serpent.Command { var ( stringFormat func(orgs []codersdk.Organization) (string, error) client = new(codersdk.Client) @@ -224,7 +224,7 @@ func (r *RootCmd) currentOrganization() *serpent.Cmd { ) onlyID = false ) - cmd := &serpent.Cmd{ + cmd := &serpent.Command{ Use: "show [current|me|uuid]", Short: "Show the organization, if no argument is given, the organization currently in use will be shown.", Middleware: serpent.Chain( diff --git a/cli/organizationmanage.go b/cli/organizationmanage.go index d4f3be2549..f5cf001802 100644 --- a/cli/organizationmanage.go +++ b/cli/organizationmanage.go @@ -12,10 +12,10 @@ import ( "github.com/coder/serpent" ) -func (r *RootCmd) createOrganization() *serpent.Cmd { +func (r *RootCmd) createOrganization() *serpent.Command { client := new(codersdk.Client) - cmd := &serpent.Cmd{ + cmd := &serpent.Command{ Use: "create ", Short: "Create a new organization.", // This action is currently irreversible, so it's hidden until we have a way to delete organizations. diff --git a/cli/ping.go b/cli/ping.go index 68130aad78..34f06d166b 100644 --- a/cli/ping.go +++ b/cli/ping.go @@ -17,7 +17,7 @@ import ( "github.com/coder/serpent" ) -func (r *RootCmd) ping() *serpent.Cmd { +func (r *RootCmd) ping() *serpent.Command { var ( pingNum int64 pingTimeout time.Duration @@ -25,7 +25,7 @@ func (r *RootCmd) ping() *serpent.Cmd { ) client := new(codersdk.Client) - cmd := &serpent.Cmd{ + cmd := &serpent.Command{ Annotations: workspaceCommand, Use: "ping ", Short: "Ping a workspace", diff --git a/cli/portforward.go b/cli/portforward.go index 064283d7c6..e4b44609d5 100644 --- a/cli/portforward.go +++ b/cli/portforward.go @@ -23,14 +23,14 @@ import ( "github.com/coder/serpent" ) -func (r *RootCmd) portForward() *serpent.Cmd { +func (r *RootCmd) portForward() *serpent.Command { var ( tcpForwards []string // : udpForwards []string // : disableAutostart bool ) client := new(codersdk.Client) - cmd := &serpent.Cmd{ + cmd := &serpent.Command{ Use: "port-forward ", Short: `Forward ports from a workspace to the local machine. For reverse port forwarding, use "coder ssh -R".`, Aliases: []string{"tunnel"}, diff --git a/cli/publickey.go b/cli/publickey.go index 2b5dec865c..03f17a4bc4 100644 --- a/cli/publickey.go +++ b/cli/publickey.go @@ -12,10 +12,10 @@ import ( "github.com/coder/coder/v2/codersdk" ) -func (r *RootCmd) publickey() *serpent.Cmd { +func (r *RootCmd) publickey() *serpent.Command { var reset bool client := new(codersdk.Client) - cmd := &serpent.Cmd{ + cmd := &serpent.Command{ Use: "publickey", Aliases: []string{"pubkey"}, Short: "Output your Coder public key used for Git operations", diff --git a/cli/rename.go b/cli/rename.go index 910f0caac4..a0176679a0 100644 --- a/cli/rename.go +++ b/cli/rename.go @@ -12,9 +12,9 @@ import ( "github.com/coder/coder/v2/codersdk" ) -func (r *RootCmd) rename() *serpent.Cmd { +func (r *RootCmd) rename() *serpent.Command { client := new(codersdk.Client) - cmd := &serpent.Cmd{ + cmd := &serpent.Command{ Annotations: workspaceCommand, Use: "rename ", Short: "Rename a workspace", diff --git a/cli/resetpassword.go b/cli/resetpassword.go index f8d3c51855..2aacc8a6e6 100644 --- a/cli/resetpassword.go +++ b/cli/resetpassword.go @@ -17,10 +17,10 @@ import ( "github.com/coder/coder/v2/coderd/userpassword" ) -func (*RootCmd) resetPassword() *serpent.Cmd { +func (*RootCmd) resetPassword() *serpent.Command { var postgresURL string - root := &serpent.Cmd{ + root := &serpent.Command{ Use: "reset-password ", Short: "Directly connect to the database to reset a user's password", Middleware: serpent.RequireNArgs(1), diff --git a/cli/resetpassword_slim.go b/cli/resetpassword_slim.go index f645b0318f..2c528d841c 100644 --- a/cli/resetpassword_slim.go +++ b/cli/resetpassword_slim.go @@ -4,8 +4,8 @@ package cli import "github.com/coder/serpent" -func (*RootCmd) resetPassword() *serpent.Cmd { - root := &serpent.Cmd{ +func (*RootCmd) resetPassword() *serpent.Command { + root := &serpent.Command{ Use: "reset-password ", Short: "Directly connect to the database to reset a user's password", // We accept RawArgs so all commands and flags are accepted. diff --git a/cli/restart.go b/cli/restart.go index 904b45825f..54ce658f8f 100644 --- a/cli/restart.go +++ b/cli/restart.go @@ -13,11 +13,11 @@ import ( "github.com/coder/serpent" ) -func (r *RootCmd) restart() *serpent.Cmd { +func (r *RootCmd) restart() *serpent.Command { var parameterFlags workspaceParameterFlags client := new(codersdk.Client) - cmd := &serpent.Cmd{ + cmd := &serpent.Command{ Annotations: workspaceCommand, Use: "restart ", Short: "Restart a workspace", diff --git a/cli/root.go b/cli/root.go index d6fc77a258..d75c319c01 100644 --- a/cli/root.go +++ b/cli/root.go @@ -84,9 +84,9 @@ var ( errUnauthenticatedURLSaved = xerrors.New(notLoggedInURLSavedMessage) ) -func (r *RootCmd) Core() []*serpent.Cmd { +func (r *RootCmd) Core() []*serpent.Command { // Please re-sort this list alphabetically if you change it! - return []*serpent.Cmd{ + return []*serpent.Command{ r.dotfiles(), r.externalAuth(), r.login(), @@ -132,13 +132,13 @@ func (r *RootCmd) Core() []*serpent.Cmd { } } -func (r *RootCmd) AGPL() []*serpent.Cmd { +func (r *RootCmd) AGPL() []*serpent.Command { all := append(r.Core(), r.Server( /* Do not import coderd here. */ nil)) return all } // Main is the entrypoint for the Coder CLI. -func (r *RootCmd) RunMain(subcommands []*serpent.Cmd) { +func (r *RootCmd) RunMain(subcommands []*serpent.Command) { rand.Seed(time.Now().UnixMicro()) cmd, err := r.Command(subcommands) @@ -166,10 +166,10 @@ func (r *RootCmd) RunMain(subcommands []*serpent.Cmd) { } } -func (r *RootCmd) Command(subcommands []*serpent.Cmd) (*serpent.Cmd, error) { +func (r *RootCmd) Command(subcommands []*serpent.Command) (*serpent.Command, error) { fmtLong := `Coder %s — A tool for provisioning self-hosted development environments with Terraform. ` - cmd := &serpent.Cmd{ + cmd := &serpent.Command{ Use: "coder [global-flags] ", Long: fmt.Sprintf(fmtLong, buildinfo.Version()) + formatExamples( example{ @@ -200,7 +200,7 @@ func (r *RootCmd) Command(subcommands []*serpent.Cmd) (*serpent.Cmd, error) { cmd.AddSubcommands(subcommands...) // Set default help handler for all commands. - cmd.Walk(func(c *serpent.Cmd) { + cmd.Walk(func(c *serpent.Command) { if c.HelpHandler == nil { c.HelpHandler = helpFn() } @@ -208,7 +208,7 @@ func (r *RootCmd) Command(subcommands []*serpent.Cmd) (*serpent.Cmd, error) { var merr error // Add [flags] to usage when appropriate. - cmd.Walk(func(cmd *serpent.Cmd) { + cmd.Walk(func(cmd *serpent.Command) { const flags = "[flags]" if strings.Contains(cmd.Use, flags) { merr = errors.Join( @@ -244,7 +244,7 @@ func (r *RootCmd) Command(subcommands []*serpent.Cmd) (*serpent.Cmd, error) { }) // Add alises when appropriate. - cmd.Walk(func(cmd *serpent.Cmd) { + cmd.Walk(func(cmd *serpent.Command) { // TODO: we should really be consistent about naming. if cmd.Name() == "delete" || cmd.Name() == "remove" { if slices.Contains(cmd.Aliases, "rm") { @@ -259,7 +259,7 @@ func (r *RootCmd) Command(subcommands []*serpent.Cmd) (*serpent.Cmd, error) { }) // Sanity-check command options. - cmd.Walk(func(cmd *serpent.Cmd) { + cmd.Walk(func(cmd *serpent.Command) { for _, opt := range cmd.Options { // Verify that every option is configurable. if opt.Flag == "" && opt.Env == "" { @@ -282,7 +282,7 @@ func (r *RootCmd) Command(subcommands []*serpent.Cmd) (*serpent.Cmd, error) { var debugOptions bool // Add a wrapper to every command to enable debugging options. - cmd.Walk(func(cmd *serpent.Cmd) { + cmd.Walk(func(cmd *serpent.Command) { h := cmd.Handler if h == nil { // We should never have a nil handler, but if we do, do not diff --git a/cli/root_test.go b/cli/root_test.go index 6a3969caf4..07439322eb 100644 --- a/cli/root_test.go +++ b/cli/root_test.go @@ -28,7 +28,7 @@ import ( //nolint:tparallel,paralleltest func TestCommandHelp(t *testing.T) { // Test with AGPL commands - getCmds := func(t *testing.T) *serpent.Cmd { + getCmds := func(t *testing.T) *serpent.Command { // Must return a fresh instance of cmds each time. t.Helper() diff --git a/cli/schedule.go b/cli/schedule.go index c5b89d1f37..a3ba597df0 100644 --- a/cli/schedule.go +++ b/cli/schedule.go @@ -53,15 +53,15 @@ When enabling scheduled stop, enter a duration in one of the following formats: ` ) -func (r *RootCmd) schedules() *serpent.Cmd { - scheduleCmd := &serpent.Cmd{ +func (r *RootCmd) schedules() *serpent.Command { + scheduleCmd := &serpent.Command{ Annotations: workspaceCommand, Use: "schedule { show | start | stop | override } ", Short: "Schedule automated start and stop times for workspaces", Handler: func(inv *serpent.Invocation) error { return inv.Command.HelpHandler(inv) }, - Children: []*serpent.Cmd{ + Children: []*serpent.Command{ r.scheduleShow(), r.scheduleStart(), r.scheduleStop(), @@ -73,7 +73,7 @@ func (r *RootCmd) schedules() *serpent.Cmd { } // scheduleShow() is just a wrapper for list() with some different defaults. -func (r *RootCmd) scheduleShow() *serpent.Cmd { +func (r *RootCmd) scheduleShow() *serpent.Command { var ( filter cliui.WorkspaceFilter formatter = cliui.NewOutputFormatter( @@ -91,7 +91,7 @@ func (r *RootCmd) scheduleShow() *serpent.Cmd { ) ) client := new(codersdk.Client) - showCmd := &serpent.Cmd{ + showCmd := &serpent.Command{ Use: "show | --all>", Short: "Show workspace schedules", Long: scheduleShowDescriptionLong, @@ -136,9 +136,9 @@ func (r *RootCmd) scheduleShow() *serpent.Cmd { return showCmd } -func (r *RootCmd) scheduleStart() *serpent.Cmd { +func (r *RootCmd) scheduleStart() *serpent.Command { client := new(codersdk.Client) - cmd := &serpent.Cmd{ + cmd := &serpent.Command{ Use: "start { [day-of-week] [location] | manual }", Long: scheduleStartDescriptionLong + "\n" + formatExamples( example{ @@ -185,9 +185,9 @@ func (r *RootCmd) scheduleStart() *serpent.Cmd { return cmd } -func (r *RootCmd) scheduleStop() *serpent.Cmd { +func (r *RootCmd) scheduleStop() *serpent.Command { client := new(codersdk.Client) - return &serpent.Cmd{ + return &serpent.Command{ Use: "stop { | manual }", Long: scheduleStopDescriptionLong + "\n" + formatExamples( example{ @@ -229,9 +229,9 @@ func (r *RootCmd) scheduleStop() *serpent.Cmd { } } -func (r *RootCmd) scheduleOverride() *serpent.Cmd { +func (r *RootCmd) scheduleOverride() *serpent.Command { client := new(codersdk.Client) - overrideCmd := &serpent.Cmd{ + overrideCmd := &serpent.Command{ Use: "override-stop ", Short: "Override the stop time of a currently running workspace instance.", Long: scheduleOverrideDescriptionLong + "\n" + formatExamples( diff --git a/cli/server.go b/cli/server.go index 7e7cd9ee7c..f57d761da7 100644 --- a/cli/server.go +++ b/cli/server.go @@ -258,7 +258,7 @@ func enablePrometheus( ), nil } -func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd.API, io.Closer, error)) *serpent.Cmd { +func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd.API, io.Closer, error)) *serpent.Command { if newAPI == nil { newAPI = func(_ context.Context, o *coderd.Options) (*coderd.API, io.Closer, error) { api := coderd.New(o) @@ -270,7 +270,7 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd. vals = new(codersdk.DeploymentValues) opts = vals.Options() ) - serverCmd := &serpent.Cmd{ + serverCmd := &serpent.Command{ Use: "server", Short: "Start a Coder server", Options: opts, @@ -1148,7 +1148,7 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd. var pgRawURL bool - postgresBuiltinURLCmd := &serpent.Cmd{ + postgresBuiltinURLCmd := &serpent.Command{ Use: "postgres-builtin-url", Short: "Output the connection URL for the built-in PostgreSQL deployment.", Handler: func(inv *serpent.Invocation) error { @@ -1165,7 +1165,7 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd. }, } - postgresBuiltinServeCmd := &serpent.Cmd{ + postgresBuiltinServeCmd := &serpent.Command{ Use: "postgres-builtin-serve", Short: "Run the built-in PostgreSQL deployment.", Handler: func(inv *serpent.Invocation) error { diff --git a/cli/server_createadminuser.go b/cli/server_createadminuser.go index 40e85d2873..2444018b11 100644 --- a/cli/server_createadminuser.go +++ b/cli/server_createadminuser.go @@ -22,7 +22,7 @@ import ( "github.com/coder/serpent" ) -func (r *RootCmd) newCreateAdminUserCommand() *serpent.Cmd { +func (r *RootCmd) newCreateAdminUserCommand() *serpent.Command { var ( newUserDBURL string newUserSSHKeygenAlgorithm string @@ -30,7 +30,7 @@ func (r *RootCmd) newCreateAdminUserCommand() *serpent.Cmd { newUserEmail string newUserPassword string ) - createAdminUserCommand := &serpent.Cmd{ + createAdminUserCommand := &serpent.Command{ Use: "create-admin-user", Short: "Create a new admin user with the given username, email and password and adds it to every organization.", Handler: func(inv *serpent.Invocation) error { diff --git a/cli/server_slim.go b/cli/server_slim.go index 012e31e974..0f2e7c7c7c 100644 --- a/cli/server_slim.go +++ b/cli/server_slim.go @@ -4,8 +4,8 @@ package cli import "github.com/coder/serpent" -func (r *RootCmd) Server(_ func()) *serpent.Cmd { - root := &serpent.Cmd{ +func (r *RootCmd) Server(_ func()) *serpent.Command { + root := &serpent.Command{ Use: "server", Short: "Start a Coder server", // We accept RawArgs so all commands and flags are accepted. diff --git a/cli/show.go b/cli/show.go index 4be4122b98..00c50292d6 100644 --- a/cli/show.go +++ b/cli/show.go @@ -8,9 +8,9 @@ import ( "github.com/coder/serpent" ) -func (r *RootCmd) show() *serpent.Cmd { +func (r *RootCmd) show() *serpent.Command { client := new(codersdk.Client) - return &serpent.Cmd{ + return &serpent.Command{ Use: "show ", Short: "Display details of a workspace's resources and agents", Middleware: serpent.Chain( diff --git a/cli/speedtest.go b/cli/speedtest.go index 12675d12fc..20697295fe 100644 --- a/cli/speedtest.go +++ b/cli/speedtest.go @@ -18,7 +18,7 @@ import ( "github.com/coder/serpent" ) -func (r *RootCmd) speedtest() *serpent.Cmd { +func (r *RootCmd) speedtest() *serpent.Command { var ( direct bool duration time.Duration @@ -26,7 +26,7 @@ func (r *RootCmd) speedtest() *serpent.Cmd { pcapFile string ) client := new(codersdk.Client) - cmd := &serpent.Cmd{ + cmd := &serpent.Command{ Annotations: workspaceCommand, Use: "speedtest ", Short: "Run upload and download tests from your machine to a workspace", diff --git a/cli/ssh.go b/cli/ssh.go index a66506bb26..4e0f1799ee 100644 --- a/cli/ssh.go +++ b/cli/ssh.go @@ -44,7 +44,7 @@ var ( autostopNotifyCountdown = []time.Duration{30 * time.Minute} ) -func (r *RootCmd) ssh() *serpent.Cmd { +func (r *RootCmd) ssh() *serpent.Command { var ( stdio bool forwardAgent bool @@ -58,7 +58,7 @@ func (r *RootCmd) ssh() *serpent.Cmd { disableAutostart bool ) client := new(codersdk.Client) - cmd := &serpent.Cmd{ + cmd := &serpent.Command{ Annotations: workspaceCommand, Use: "ssh ", Short: "Start a shell into a workspace", diff --git a/cli/start.go b/cli/start.go index b60f726fc0..b0f0a4be4b 100644 --- a/cli/start.go +++ b/cli/start.go @@ -12,11 +12,11 @@ import ( "github.com/coder/serpent" ) -func (r *RootCmd) start() *serpent.Cmd { +func (r *RootCmd) start() *serpent.Command { var parameterFlags workspaceParameterFlags client := new(codersdk.Client) - cmd := &serpent.Cmd{ + cmd := &serpent.Command{ Annotations: workspaceCommand, Use: "start ", Short: "Start a workspace", diff --git a/cli/stat.go b/cli/stat.go index f63eb98f4e..37fc113fce 100644 --- a/cli/stat.go +++ b/cli/stat.go @@ -26,7 +26,7 @@ func initStatterMW(tgt **clistat.Statter, fs afero.Fs) serpent.MiddlewareFunc { } } -func (r *RootCmd) stat() *serpent.Cmd { +func (r *RootCmd) stat() *serpent.Command { var ( st *clistat.Statter fs = afero.NewReadOnlyFs(afero.NewOsFs()) @@ -41,11 +41,11 @@ func (r *RootCmd) stat() *serpent.Cmd { cliui.JSONFormat(), ) ) - cmd := &serpent.Cmd{ + cmd := &serpent.Command{ Use: "stat", Short: "Show resource usage for the current workspace.", Middleware: initStatterMW(&st, fs), - Children: []*serpent.Cmd{ + Children: []*serpent.Command{ r.statCPU(fs), r.statMem(fs), r.statDisk(fs), @@ -130,13 +130,13 @@ func (r *RootCmd) stat() *serpent.Cmd { return cmd } -func (*RootCmd) statCPU(fs afero.Fs) *serpent.Cmd { +func (*RootCmd) statCPU(fs afero.Fs) *serpent.Command { var ( hostArg bool st *clistat.Statter formatter = cliui.NewOutputFormatter(cliui.TextFormat(), cliui.JSONFormat()) ) - cmd := &serpent.Cmd{ + cmd := &serpent.Command{ Use: "cpu", Short: "Show CPU usage, in cores.", Middleware: initStatterMW(&st, fs), @@ -171,14 +171,14 @@ func (*RootCmd) statCPU(fs afero.Fs) *serpent.Cmd { return cmd } -func (*RootCmd) statMem(fs afero.Fs) *serpent.Cmd { +func (*RootCmd) statMem(fs afero.Fs) *serpent.Command { var ( hostArg bool prefixArg string st *clistat.Statter formatter = cliui.NewOutputFormatter(cliui.TextFormat(), cliui.JSONFormat()) ) - cmd := &serpent.Cmd{ + cmd := &serpent.Command{ Use: "mem", Short: "Show memory usage, in gigabytes.", Middleware: initStatterMW(&st, fs), @@ -225,14 +225,14 @@ func (*RootCmd) statMem(fs afero.Fs) *serpent.Cmd { return cmd } -func (*RootCmd) statDisk(fs afero.Fs) *serpent.Cmd { +func (*RootCmd) statDisk(fs afero.Fs) *serpent.Command { var ( pathArg string prefixArg string st *clistat.Statter formatter = cliui.NewOutputFormatter(cliui.TextFormat(), cliui.JSONFormat()) ) - cmd := &serpent.Cmd{ + cmd := &serpent.Command{ Use: "disk", Short: "Show disk usage, in gigabytes.", Middleware: initStatterMW(&st, fs), diff --git a/cli/state.go b/cli/state.go index d2183e7dd8..7469c77d6f 100644 --- a/cli/state.go +++ b/cli/state.go @@ -11,14 +11,14 @@ import ( "github.com/coder/serpent" ) -func (r *RootCmd) state() *serpent.Cmd { - cmd := &serpent.Cmd{ +func (r *RootCmd) state() *serpent.Command { + cmd := &serpent.Command{ Use: "state", Short: "Manually manage Terraform state to fix broken workspaces", Handler: func(inv *serpent.Invocation) error { return inv.Command.HelpHandler(inv) }, - Children: []*serpent.Cmd{ + Children: []*serpent.Command{ r.statePull(), r.statePush(), }, @@ -26,10 +26,10 @@ func (r *RootCmd) state() *serpent.Cmd { return cmd } -func (r *RootCmd) statePull() *serpent.Cmd { +func (r *RootCmd) statePull() *serpent.Command { var buildNumber int64 client := new(codersdk.Client) - cmd := &serpent.Cmd{ + cmd := &serpent.Command{ Use: "pull [file]", Short: "Pull a Terraform state file from a workspace.", Middleware: serpent.Chain( @@ -84,10 +84,10 @@ func buildNumberOption(n *int64) serpent.Option { } } -func (r *RootCmd) statePush() *serpent.Cmd { +func (r *RootCmd) statePush() *serpent.Command { var buildNumber int64 client := new(codersdk.Client) - cmd := &serpent.Cmd{ + cmd := &serpent.Command{ Use: "push ", Short: "Push a Terraform state file to a workspace.", Middleware: serpent.Chain( diff --git a/cli/stop.go b/cli/stop.go index 8757d9ee57..890f027580 100644 --- a/cli/stop.go +++ b/cli/stop.go @@ -9,9 +9,9 @@ import ( "github.com/coder/serpent" ) -func (r *RootCmd) stop() *serpent.Cmd { +func (r *RootCmd) stop() *serpent.Command { client := new(codersdk.Client) - cmd := &serpent.Cmd{ + cmd := &serpent.Command{ Annotations: workspaceCommand, Use: "stop ", Short: "Stop a workspace", diff --git a/cli/support.go b/cli/support.go index d27867fa31..d9295e2d2b 100644 --- a/cli/support.go +++ b/cli/support.go @@ -21,25 +21,25 @@ import ( "github.com/coder/serpent" ) -func (r *RootCmd) support() *serpent.Cmd { - supportCmd := &serpent.Cmd{ +func (r *RootCmd) support() *serpent.Command { + supportCmd := &serpent.Command{ Use: "support", Short: "Commands for troubleshooting issues with a Coder deployment.", Handler: func(inv *serpent.Invocation) error { return inv.Command.HelpHandler(inv) }, Hidden: true, // TODO: un-hide once the must-haves from #12160 are completed. - Children: []*serpent.Cmd{ + Children: []*serpent.Command{ r.supportBundle(), }, } return supportCmd } -func (r *RootCmd) supportBundle() *serpent.Cmd { +func (r *RootCmd) supportBundle() *serpent.Command { var outputPath string client := new(codersdk.Client) - cmd := &serpent.Cmd{ + cmd := &serpent.Command{ Use: "bundle []", Short: "Generate a support bundle to troubleshoot issues connecting to a workspace.", Long: `This command generates a file containing detailed troubleshooting information about the Coder deployment and workspace connections. You must specify a single workspace (and optionally an agent name).`, diff --git a/cli/templatecreate.go b/cli/templatecreate.go index e1d903c9f4..16c0f684cd 100644 --- a/cli/templatecreate.go +++ b/cli/templatecreate.go @@ -16,7 +16,7 @@ import ( "github.com/coder/coder/v2/codersdk" ) -func (r *RootCmd) templateCreate() *serpent.Cmd { +func (r *RootCmd) templateCreate() *serpent.Command { var ( provisioner string provisionerTags []string @@ -34,7 +34,7 @@ func (r *RootCmd) templateCreate() *serpent.Cmd { uploadFlags templateUploadFlags ) client := new(codersdk.Client) - cmd := &serpent.Cmd{ + cmd := &serpent.Command{ Use: "create [name]", Short: "DEPRECATED: Create a template from the current directory or as specified by flag", Middleware: serpent.Chain( diff --git a/cli/templatedelete.go b/cli/templatedelete.go index 01c2991912..7ded11dd8f 100644 --- a/cli/templatedelete.go +++ b/cli/templatedelete.go @@ -14,9 +14,9 @@ import ( "github.com/coder/serpent" ) -func (r *RootCmd) templateDelete() *serpent.Cmd { +func (r *RootCmd) templateDelete() *serpent.Command { client := new(codersdk.Client) - cmd := &serpent.Cmd{ + cmd := &serpent.Command{ Use: "delete [name...]", Short: "Delete templates", Middleware: serpent.Chain( diff --git a/cli/templateedit.go b/cli/templateedit.go index 523a01dbfe..c714948335 100644 --- a/cli/templateedit.go +++ b/cli/templateedit.go @@ -15,7 +15,7 @@ import ( "github.com/coder/coder/v2/codersdk" ) -func (r *RootCmd) templateEdit() *serpent.Cmd { +func (r *RootCmd) templateEdit() *serpent.Command { const deprecatedFlagName = "deprecated" var ( name string @@ -40,7 +40,7 @@ func (r *RootCmd) templateEdit() *serpent.Cmd { ) client := new(codersdk.Client) - cmd := &serpent.Cmd{ + cmd := &serpent.Command{ Use: "edit