From 5a5feb047d2218d4c85cceb70d07d0d85bd9da47 Mon Sep 17 00:00:00 2001 From: Ethan Dickson Date: Fri, 9 Aug 2024 07:04:23 +0000 Subject: [PATCH] feat(cli): add shell completions --- cli/cliui/output.go | 8 +- cli/cliui/output_test.go | 17 ++-- cli/completion.go | 89 +++++++++++++++++++ cli/configssh.go | 47 +--------- cli/help.go | 2 + cli/organizationmembers.go | 2 +- cli/organizationmembers_test.go | 2 +- cli/organizationroles.go | 14 +-- cli/root.go | 1 + cli/stat.go | 20 ++--- cli/templateedit.go | 28 +----- cli/templateversions.go | 14 +-- cli/testdata/coder_--help.golden | 2 + cli/testdata/coder_completion_--help.golden | 16 ++++ cli/testdata/coder_list_--help.golden | 13 ++- .../coder_schedule_show_--help.golden | 9 +- cli/testdata/coder_speedtest_--help.golden | 9 +- cli/testdata/coder_stat_--help.golden | 9 +- cli/testdata/coder_stat_cpu_--help.golden | 4 +- cli/testdata/coder_stat_disk_--help.golden | 4 +- cli/testdata/coder_stat_mem_--help.golden | 4 +- .../coder_templates_edit_--help.golden | 4 +- .../coder_templates_list_--help.golden | 10 +-- ...oder_templates_versions_list_--help.golden | 9 +- cli/testdata/coder_tokens_list_--help.golden | 9 +- .../coder_users_activate_--help.golden | 2 +- cli/testdata/coder_users_list_--help.golden | 9 +- cli/testdata/coder_users_show_--help.golden | 4 +- .../coder_users_suspend_--help.golden | 2 +- cli/testdata/coder_version_--help.golden | 4 +- cli/userlist.go | 2 +- cli/userstatus.go | 5 +- codersdk/organizations.go | 8 +- codersdk/provisionerdaemons.go | 4 +- codersdk/roles.go | 18 ++-- codersdk/templates.go | 2 + codersdk/workspaceproxy.go | 16 ++-- docs/manifest.json | 5 ++ docs/reference/cli/README.md | 1 + docs/reference/cli/completion.md | 29 ++++++ docs/reference/cli/config-ssh.md | 2 +- docs/reference/cli/features_list.md | 20 ++--- docs/reference/cli/groups_list.md | 20 ++--- docs/reference/cli/licenses_list.md | 20 ++--- docs/reference/cli/list.md | 20 ++--- docs/reference/cli/schedule_show.md | 20 ++--- docs/reference/cli/server.md | 12 +-- .../reference/cli/server_create-admin-user.md | 2 +- docs/reference/cli/server_dbcrypt_decrypt.md | 2 +- docs/reference/cli/server_dbcrypt_delete.md | 2 +- docs/reference/cli/server_dbcrypt_rotate.md | 2 +- docs/reference/cli/speedtest.md | 28 +++--- docs/reference/cli/ssh.md | 10 +-- docs/reference/cli/stat.md | 20 ++--- docs/reference/cli/stat_cpu.md | 10 +-- docs/reference/cli/stat_disk.md | 18 ++-- docs/reference/cli/stat_mem.md | 18 ++-- docs/reference/cli/templates_edit.md | 12 +-- docs/reference/cli/templates_init.md | 6 +- docs/reference/cli/templates_list.md | 20 ++--- docs/reference/cli/templates_versions_list.md | 20 ++--- docs/reference/cli/tokens_list.md | 20 ++--- docs/reference/cli/users_activate.md | 8 +- docs/reference/cli/users_list.md | 20 ++--- docs/reference/cli/users_show.md | 10 +-- docs/reference/cli/users_suspend.md | 8 +- docs/reference/cli/version.md | 10 +-- enterprise/cli/features.go | 14 ++- enterprise/cli/grouplist.go | 6 +- enterprise/cli/licenses.go | 4 +- enterprise/cli/organizationmembers_test.go | 2 +- .../coder_features_list_--help.golden | 9 +- .../testdata/coder_groups_list_--help.golden | 9 +- .../coder_licenses_list_--help.golden | 9 +- enterprise/cli/workspaceproxy.go | 2 +- flake.nix | 2 +- go.mod | 13 +-- go.sum | 31 +++++-- scripts/clidocgen/command.tpl | 2 +- scripts/clidocgen/gen.go | 10 +++ 80 files changed, 511 insertions(+), 419 deletions(-) create mode 100644 cli/completion.go create mode 100644 cli/testdata/coder_completion_--help.golden create mode 100644 docs/reference/cli/completion.md diff --git a/cli/cliui/output.go b/cli/cliui/output.go index d15d18b63fe18..b875e19d154c3 100644 --- a/cli/cliui/output.go +++ b/cli/cliui/output.go @@ -65,8 +65,8 @@ func (f *OutputFormatter) AttachOptions(opts *serpent.OptionSet) { Flag: "output", FlagShorthand: "o", Default: f.formats[0].ID(), - Value: serpent.StringOf(&f.formatID), - Description: "Output format. Available formats: " + strings.Join(formatNames, ", ") + ".", + Value: serpent.EnumOf(&f.formatID, formatNames...), + Description: "Output format.", }, ) } @@ -136,8 +136,8 @@ func (f *tableFormat) AttachOptions(opts *serpent.OptionSet) { Flag: "column", FlagShorthand: "c", Default: strings.Join(f.defaultColumns, ","), - Value: serpent.StringArrayOf(&f.columns), - Description: "Columns to display in table output. Available columns: " + strings.Join(f.allColumns, ", ") + ".", + Value: serpent.EnumArrayOf(&f.columns, f.allColumns...), + Description: "Columns to display in table output.", }, ) } diff --git a/cli/cliui/output_test.go b/cli/cliui/output_test.go index 7e7912b5a608e..3d413aad5caf3 100644 --- a/cli/cliui/output_test.go +++ b/cli/cliui/output_test.go @@ -106,11 +106,11 @@ func Test_OutputFormatter(t *testing.T) { fs := cmd.Options.FlagSet() - selected, err := fs.GetString("output") - require.NoError(t, err) - require.Equal(t, "json", selected) + selected := cmd.Options.ByFlag("output") + require.NotNil(t, selected) + require.Equal(t, "json", selected.Value.String()) usage := fs.FlagUsages() - require.Contains(t, usage, "Available formats: json, foo") + require.Contains(t, usage, "Output format.") require.Contains(t, usage, "foo flag 1234") ctx := context.Background() @@ -129,11 +129,10 @@ func Test_OutputFormatter(t *testing.T) { require.Equal(t, "foo", out) require.EqualValues(t, 1, atomic.LoadInt64(&called)) - require.NoError(t, fs.Set("output", "bar")) + require.Error(t, fs.Set("output", "bar")) out, err = f.Format(ctx, data) - require.Error(t, err) - require.ErrorContains(t, err, "bar") - require.Equal(t, "", out) - require.EqualValues(t, 1, atomic.LoadInt64(&called)) + require.NoError(t, err) + require.Equal(t, "foo", out) + require.EqualValues(t, 2, atomic.LoadInt64(&called)) }) } diff --git a/cli/completion.go b/cli/completion.go new file mode 100644 index 0000000000000..46169a47c6ac5 --- /dev/null +++ b/cli/completion.go @@ -0,0 +1,89 @@ +package cli + +import ( + "fmt" + + "github.com/coder/coder/v2/cli/cliui" + "github.com/coder/serpent" + "github.com/coder/serpent/completion" +) + +func (*RootCmd) completion() *serpent.Command { + var shellName string + var printOutput bool + shellOptions := completion.ShellOptions(&shellName) + return &serpent.Command{ + Use: "completion", + Short: "Install or update shell completion scripts for the detected or chosen shell.", + Options: []serpent.Option{ + { + Flag: "shell", + FlagShorthand: "s", + Description: "The shell to install completion for.", + Value: shellOptions, + }, + { + Flag: "print", + Description: "Print the completion script instead of installing it.", + FlagShorthand: "p", + + Value: serpent.BoolOf(&printOutput), + }, + }, + Handler: func(inv *serpent.Invocation) error { + if shellName != "" { + shell, err := completion.ShellByName(shellName, inv.Command.Parent.Name()) + if err != nil { + return err + } + if printOutput { + return shell.WriteCompletion(inv.Stdout) + } + return installCompletion(inv, shell) + } + shell, err := completion.DetectUserShell(inv.Command.Parent.Name()) + if err == nil { + return installCompletion(inv, shell) + } + // Silently continue to the shell selection if detecting failed. + choice, err := cliui.Select(inv, cliui.SelectOptions{ + Message: "Select a shell to install completion for:", + Options: shellOptions.Choices, + }) + if err != nil { + return err + } + shellChoice, err := completion.ShellByName(choice, inv.Command.Parent.Name()) + if err != nil { + return err + } + if printOutput { + return shellChoice.WriteCompletion(inv.Stdout) + } + return installCompletion(inv, shellChoice) + }, + } +} + +func installCompletion(inv *serpent.Invocation, shell completion.Shell) error { + path, err := shell.InstallPath() + if err != nil { + cliui.Error(inv.Stderr, fmt.Sprintf("Failed to determine completion path %v", err)) + return shell.WriteCompletion(inv.Stdout) + } + choice, err := cliui.Select(inv, cliui.SelectOptions{ + Options: []string{ + "Confirm", + "Print to terminal", + }, + Message: fmt.Sprintf("Install completion for %s at %s?", shell.Name(), path), + HideSearch: true, + }) + if err != nil { + return err + } + if choice == "Print to terminal" { + return shell.WriteCompletion(inv.Stdout) + } + return completion.InstallShellCompletion(shell) +} diff --git a/cli/configssh.go b/cli/configssh.go index 3741c5ceec25e..cdaf404ab50df 100644 --- a/cli/configssh.go +++ b/cli/configssh.go @@ -17,6 +17,7 @@ import ( "strings" "github.com/cli/safeexec" + "github.com/natefinch/atomic" "github.com/pkg/diff" "github.com/pkg/diff/write" "golang.org/x/exp/constraints" @@ -524,7 +525,7 @@ func (r *RootCmd) configSSH() *serpent.Command { } if !bytes.Equal(configRaw, configModified) { - err = writeWithTempFileAndMove(sshConfigFile, bytes.NewReader(configModified)) + err = atomic.WriteFile(sshConfigFile, bytes.NewReader(configModified)) if err != nil { return xerrors.Errorf("write ssh config failed: %w", err) } @@ -758,50 +759,6 @@ func sshConfigSplitOnCoderSection(data []byte) (before, section []byte, after [] return data, nil, nil, nil } -// writeWithTempFileAndMove writes to a temporary file in the same -// directory as path and renames the temp file to the file provided in -// path. This ensure we avoid trashing the file we are writing due to -// unforeseen circumstance like filesystem full, command killed, etc. -func writeWithTempFileAndMove(path string, r io.Reader) (err error) { - dir := filepath.Dir(path) - name := filepath.Base(path) - - // Ensure that e.g. the ~/.ssh directory exists. - if err = os.MkdirAll(dir, 0o700); err != nil { - return xerrors.Errorf("create directory: %w", err) - } - - // Create a tempfile in the same directory for ensuring write - // operation does not fail. - f, err := os.CreateTemp(dir, fmt.Sprintf(".%s.", name)) - if err != nil { - return xerrors.Errorf("create temp file failed: %w", err) - } - defer func() { - if err != nil { - _ = os.Remove(f.Name()) // Cleanup in case a step failed. - } - }() - - _, err = io.Copy(f, r) - if err != nil { - _ = f.Close() - return xerrors.Errorf("write temp file failed: %w", err) - } - - err = f.Close() - if err != nil { - return xerrors.Errorf("close temp file failed: %w", err) - } - - err = os.Rename(f.Name(), path) - if err != nil { - return xerrors.Errorf("rename temp file failed: %w", err) - } - - return nil -} - // sshConfigExecEscape quotes the string if it contains spaces, as per // `man 5 ssh_config`. However, OpenSSH uses exec in the users shell to // run the command, and as such the formatting/escape requirements diff --git a/cli/help.go b/cli/help.go index 4ece61b437545..b4b0a1e20caf5 100644 --- a/cli/help.go +++ b/cli/help.go @@ -81,6 +81,8 @@ var usageTemplate = func() *template.Template { switch v := opt.Value.(type) { case *serpent.Enum: return strings.Join(v.Choices, "|") + case *serpent.EnumArray: + return fmt.Sprintf("[%s]", strings.Join(v.Choices, "|")) default: return v.Type() } diff --git a/cli/organizationmembers.go b/cli/organizationmembers.go index bbd4d8519e1d1..26208cb5db906 100644 --- a/cli/organizationmembers.go +++ b/cli/organizationmembers.go @@ -137,7 +137,7 @@ func (r *RootCmd) assignOrganizationRoles(orgContext *OrganizationContext) *serp func (r *RootCmd) listOrganizationMembers(orgContext *OrganizationContext) *serpent.Command { formatter := cliui.NewOutputFormatter( - cliui.TableFormat([]codersdk.OrganizationMemberWithUserData{}, []string{"username", "organization_roles"}), + cliui.TableFormat([]codersdk.OrganizationMemberWithUserData{}, []string{"username", "organization roles"}), cliui.JSONFormat(), ) diff --git a/cli/organizationmembers_test.go b/cli/organizationmembers_test.go index 6cd8b9d3ccd4a..97a174626cdaf 100644 --- a/cli/organizationmembers_test.go +++ b/cli/organizationmembers_test.go @@ -23,7 +23,7 @@ func TestListOrganizationMembers(t *testing.T) { client, user := coderdtest.CreateAnotherUser(t, ownerClient, owner.OrganizationID, rbac.RoleUserAdmin()) ctx := testutil.Context(t, testutil.WaitMedium) - inv, root := clitest.New(t, "organization", "members", "list", "-c", "user_id,username,roles") + inv, root := clitest.New(t, "organization", "members", "list", "-c", "user id,username,organization roles") clitest.SetupConfig(t, client, root) buf := new(bytes.Buffer) diff --git a/cli/organizationroles.go b/cli/organizationroles.go index dd40d48fb0b36..71e1b38be7d3b 100644 --- a/cli/organizationroles.go +++ b/cli/organizationroles.go @@ -36,7 +36,7 @@ func (r *RootCmd) organizationRoles(orgContext *OrganizationContext) *serpent.Co func (r *RootCmd) showOrganizationRoles(orgContext *OrganizationContext) *serpent.Command { formatter := cliui.NewOutputFormatter( cliui.ChangeFormatterData( - cliui.TableFormat([]roleTableRow{}, []string{"name", "display_name", "site_permissions", "organization_permissions", "user_permissions"}), + cliui.TableFormat([]roleTableRow{}, []string{"name", "display name", "site permissions", "organization permissions", "user permissions"}), func(data any) (any, error) { inputs, ok := data.([]codersdk.AssignableRoles) if !ok { @@ -103,7 +103,7 @@ func (r *RootCmd) showOrganizationRoles(orgContext *OrganizationContext) *serpen func (r *RootCmd) editOrganizationRole(orgContext *OrganizationContext) *serpent.Command { formatter := cliui.NewOutputFormatter( cliui.ChangeFormatterData( - cliui.TableFormat([]roleTableRow{}, []string{"name", "display_name", "site_permissions", "organization_permissions", "user_permissions"}), + cliui.TableFormat([]roleTableRow{}, []string{"name", "display name", "site permissions", "organization permissions", "user permissions"}), func(data any) (any, error) { typed, _ := data.(codersdk.Role) return []roleTableRow{roleToTableView(typed)}, nil @@ -408,10 +408,10 @@ func roleToTableView(role codersdk.Role) roleTableRow { type roleTableRow struct { Name string `table:"name,default_sort"` - DisplayName string `table:"display_name"` - OrganizationID string `table:"organization_id"` - SitePermissions string ` table:"site_permissions"` + DisplayName string `table:"display name"` + OrganizationID string `table:"organization id"` + SitePermissions string ` table:"site permissions"` // map[] -> Permissions - OrganizationPermissions string `table:"organization_permissions"` - UserPermissions string `table:"user_permissions"` + OrganizationPermissions string `table:"organization permissions"` + UserPermissions string `table:"user permissions"` } diff --git a/cli/root.go b/cli/root.go index 22d153c00f7f1..fdebdc74bedde 100644 --- a/cli/root.go +++ b/cli/root.go @@ -82,6 +82,7 @@ const ( func (r *RootCmd) CoreSubcommands() []*serpent.Command { // Please re-sort this list alphabetically if you change it! return []*serpent.Command{ + r.completion(), r.dotfiles(), r.externalAuth(), r.login(), diff --git a/cli/stat.go b/cli/stat.go index 37fc113fce370..aee7847cf70d1 100644 --- a/cli/stat.go +++ b/cli/stat.go @@ -32,11 +32,11 @@ func (r *RootCmd) stat() *serpent.Command { fs = afero.NewReadOnlyFs(afero.NewOsFs()) formatter = cliui.NewOutputFormatter( cliui.TableFormat([]statsRow{}, []string{ - "host_cpu", - "host_memory", - "home_disk", - "container_cpu", - "container_memory", + "host cpu", + "host memory", + "home disk", + "container cpu", + "container memory", }), cliui.JSONFormat(), ) @@ -284,9 +284,9 @@ func (*RootCmd) statDisk(fs afero.Fs) *serpent.Command { } type statsRow struct { - HostCPU *clistat.Result `json:"host_cpu" table:"host_cpu,default_sort"` - HostMemory *clistat.Result `json:"host_memory" table:"host_memory"` - Disk *clistat.Result `json:"home_disk" table:"home_disk"` - ContainerCPU *clistat.Result `json:"container_cpu" table:"container_cpu"` - ContainerMemory *clistat.Result `json:"container_memory" table:"container_memory"` + HostCPU *clistat.Result `json:"host_cpu" table:"host cpu,default_sort"` + HostMemory *clistat.Result `json:"host_memory" table:"host memory"` + Disk *clistat.Result `json:"home_disk" table:"home disk"` + ContainerCPU *clistat.Result `json:"container_cpu" table:"container cpu"` + ContainerMemory *clistat.Result `json:"container_memory" table:"container memory"` } diff --git a/cli/templateedit.go b/cli/templateedit.go index 4ac9c56f92534..aba146d1958e4 100644 --- a/cli/templateedit.go +++ b/cli/templateedit.go @@ -3,7 +3,6 @@ package cli import ( "fmt" "net/http" - "strings" "time" "golang.org/x/xerrors" @@ -239,35 +238,14 @@ func (r *RootCmd) templateEdit() *serpent.Command { Value: serpent.DurationOf(&activityBump), }, { - Flag: "autostart-requirement-weekdays", - // workspaces created from this template must be restarted on the given weekdays. To unset this value for the template (and disable the autostop requirement for the template), pass 'none'. + Flag: "autostart-requirement-weekdays", Description: "Edit the template autostart requirement weekdays - workspaces created from this template can only autostart on the given weekdays. To unset this value for the template (and allow autostart on all days), pass 'all'.", - Value: serpent.Validate(serpent.StringArrayOf(&autostartRequirementDaysOfWeek), func(value *serpent.StringArray) error { - v := value.GetSlice() - if len(v) == 1 && v[0] == "all" { - return nil - } - _, err := codersdk.WeekdaysToBitmap(v) - if err != nil { - return xerrors.Errorf("invalid autostart requirement days of week %q: %w", strings.Join(v, ","), err) - } - return nil - }), + Value: serpent.EnumArrayOf(&autostartRequirementDaysOfWeek, append(codersdk.AllDaysOfWeek, "all")...), }, { Flag: "autostop-requirement-weekdays", Description: "Edit the template autostop requirement weekdays - workspaces created from this template must be restarted on the given weekdays. To unset this value for the template (and disable the autostop requirement for the template), pass 'none'.", - Value: serpent.Validate(serpent.StringArrayOf(&autostopRequirementDaysOfWeek), func(value *serpent.StringArray) error { - v := value.GetSlice() - if len(v) == 1 && v[0] == "none" { - return nil - } - _, err := codersdk.WeekdaysToBitmap(v) - if err != nil { - return xerrors.Errorf("invalid autostop requirement days of week %q: %w", strings.Join(v, ","), err) - } - return nil - }), + Value: serpent.EnumArrayOf(&autostopRequirementDaysOfWeek, append(codersdk.AllDaysOfWeek, "none")...), }, { Flag: "autostop-requirement-weeks", diff --git a/cli/templateversions.go b/cli/templateversions.go index 9154e6724291d..1f6cb11d4a8dd 100644 --- a/cli/templateversions.go +++ b/cli/templateversions.go @@ -40,11 +40,11 @@ func (r *RootCmd) templateVersions() *serpent.Command { func (r *RootCmd) templateVersionsList() *serpent.Command { defaultColumns := []string{ - "Name", - "Created At", - "Created By", - "Status", - "Active", + "name", + "created at", + "created by", + "status", + "active", } formatter := cliui.NewOutputFormatter( cliui.TableFormat([]templateVersionRow{}, defaultColumns), @@ -70,10 +70,10 @@ func (r *RootCmd) templateVersionsList() *serpent.Command { for _, opt := range i.Command.Options { if opt.Flag == "column" { if opt.ValueSource == serpent.ValueSourceDefault { - v, ok := opt.Value.(*serpent.StringArray) + v, ok := opt.Value.(*serpent.EnumArray) if ok { // Add the extra new default column. - *v = append(*v, "Archived") + _ = v.Append("Archived") } } break diff --git a/cli/testdata/coder_--help.golden b/cli/testdata/coder_--help.golden index 494ed7decb492..2ebbc458e1b6b 100644 --- a/cli/testdata/coder_--help.golden +++ b/cli/testdata/coder_--help.golden @@ -15,6 +15,8 @@ USAGE: SUBCOMMANDS: autoupdate Toggle auto-update policy for a workspace + completion Install or update shell completion scripts for the + detected or chosen shell. config-ssh Add an SSH Host entry for your workspaces "ssh coder.workspace" create Create a workspace diff --git a/cli/testdata/coder_completion_--help.golden b/cli/testdata/coder_completion_--help.golden new file mode 100644 index 0000000000000..974fcfd53d0b4 --- /dev/null +++ b/cli/testdata/coder_completion_--help.golden @@ -0,0 +1,16 @@ +coder v0.0.0-devel + +USAGE: + coder completion [flags] + + Install or update shell completion scripts for the detected or chosen shell. + +OPTIONS: + -p, --print bool + Print the completion script instead of installing it. + + -s, --shell bash|fish|zsh|powershell + The shell to install completion for. + +——— +Run `coder --help` for a list of global options. diff --git a/cli/testdata/coder_list_--help.golden b/cli/testdata/coder_list_--help.golden index 407260244cc45..e5afbc02ca983 100644 --- a/cli/testdata/coder_list_--help.golden +++ b/cli/testdata/coder_list_--help.golden @@ -11,14 +11,11 @@ OPTIONS: -a, --all bool Specifies whether all workspaces will be listed or not. - -c, --column string-array (default: workspace,template,status,healthy,last built,current version,outdated,starts at,stops after) - Columns to display in table output. Available columns: favorite, - workspace, organization id, organization name, template, status, - healthy, last built, current version, outdated, starts at, starts - next, stops after, stops next, daily cost. - - -o, --output string (default: table) - Output format. Available formats: table, json. + -c, --column [favorite|workspace|organization id|organization name|template|status|healthy|last built|current version|outdated|starts at|starts next|stops after|stops next|daily cost] (default: workspace,template,status,healthy,last built,current version,outdated,starts at,stops after) + Columns to display in table output. + + -o, --output table|json (default: table) + Output format. --search string (default: owner:me) Search for a workspace with a query. diff --git a/cli/testdata/coder_schedule_show_--help.golden b/cli/testdata/coder_schedule_show_--help.golden index 34b49fb5993f7..5e1de846bd3df 100644 --- a/cli/testdata/coder_schedule_show_--help.golden +++ b/cli/testdata/coder_schedule_show_--help.golden @@ -15,12 +15,11 @@ OPTIONS: -a, --all bool Specifies whether all workspaces will be listed or not. - -c, --column string-array (default: workspace,starts at,starts next,stops after,stops next) - Columns to display in table output. Available columns: workspace, - starts at, starts next, stops after, stops next. + -c, --column [workspace|starts at|starts next|stops after|stops next] (default: workspace,starts at,starts next,stops after,stops next) + Columns to display in table output. - -o, --output string (default: table) - Output format. Available formats: table, json. + -o, --output table|json (default: table) + Output format. --search string (default: owner:me) Search for a workspace with a query. diff --git a/cli/testdata/coder_speedtest_--help.golden b/cli/testdata/coder_speedtest_--help.golden index 538c955fae252..bb70edac9bea2 100644 --- a/cli/testdata/coder_speedtest_--help.golden +++ b/cli/testdata/coder_speedtest_--help.golden @@ -6,9 +6,8 @@ USAGE: Run upload and download tests from your machine to a workspace OPTIONS: - -c, --column string-array (default: Interval,Throughput) - Columns to display in table output. Available columns: Interval, - Throughput. + -c, --column [Interval|Throughput] (default: Interval,Throughput) + Columns to display in table output. -d, --direct bool Specifies whether to wait for a direct connection before testing @@ -18,8 +17,8 @@ OPTIONS: Specifies whether to run in reverse mode where the client receives and the server sends. - -o, --output string (default: table) - Output format. Available formats: table, json. + -o, --output table|json (default: table) + Output format. --pcap-file string Specifies a file to write a network capture to. diff --git a/cli/testdata/coder_stat_--help.golden b/cli/testdata/coder_stat_--help.golden index e8557f5059827..508bc59577b05 100644 --- a/cli/testdata/coder_stat_--help.golden +++ b/cli/testdata/coder_stat_--help.golden @@ -11,12 +11,11 @@ SUBCOMMANDS: mem Show memory usage, in gigabytes. OPTIONS: - -c, --column string-array (default: host_cpu,host_memory,home_disk,container_cpu,container_memory) - Columns to display in table output. Available columns: host cpu, host - memory, home disk, container cpu, container memory. + -c, --column [host cpu|host memory|home disk|container cpu|container memory] (default: host cpu,host memory,home disk,container cpu,container memory) + Columns to display in table output. - -o, --output string (default: table) - Output format. Available formats: table, json. + -o, --output table|json (default: table) + Output format. ——— Run `coder --help` for a list of global options. diff --git a/cli/testdata/coder_stat_cpu_--help.golden b/cli/testdata/coder_stat_cpu_--help.golden index ec92a6845704f..ca9519b8f8e6d 100644 --- a/cli/testdata/coder_stat_cpu_--help.golden +++ b/cli/testdata/coder_stat_cpu_--help.golden @@ -9,8 +9,8 @@ OPTIONS: --host bool Force host CPU measurement. - -o, --output string (default: text) - Output format. Available formats: text, json. + -o, --output text|json (default: text) + Output format. ——— Run `coder --help` for a list of global options. diff --git a/cli/testdata/coder_stat_disk_--help.golden b/cli/testdata/coder_stat_disk_--help.golden index 815d81bc45362..c63a05a064cbd 100644 --- a/cli/testdata/coder_stat_disk_--help.golden +++ b/cli/testdata/coder_stat_disk_--help.golden @@ -6,8 +6,8 @@ USAGE: Show disk usage, in gigabytes. OPTIONS: - -o, --output string (default: text) - Output format. Available formats: text, json. + -o, --output text|json (default: text) + Output format. --path string (default: /) Path for which to check disk usage. diff --git a/cli/testdata/coder_stat_mem_--help.golden b/cli/testdata/coder_stat_mem_--help.golden index 97eaaff83604a..4aa84f90eaa5a 100644 --- a/cli/testdata/coder_stat_mem_--help.golden +++ b/cli/testdata/coder_stat_mem_--help.golden @@ -9,8 +9,8 @@ OPTIONS: --host bool Force host memory measurement. - -o, --output string (default: text) - Output format. Available formats: text, json. + -o, --output text|json (default: text) + Output format. --prefix Ki|Mi|Gi|Ti (default: Gi) SI Prefix for memory measurement. diff --git a/cli/testdata/coder_templates_edit_--help.golden b/cli/testdata/coder_templates_edit_--help.golden index 6c33faa3d9c3b..12fdf0fec3a13 100644 --- a/cli/testdata/coder_templates_edit_--help.golden +++ b/cli/testdata/coder_templates_edit_--help.golden @@ -25,13 +25,13 @@ OPTIONS: --allow-user-cancel-workspace-jobs bool (default: true) Allow users to cancel in-progress workspace jobs. - --autostart-requirement-weekdays string-array + --autostart-requirement-weekdays [monday|tuesday|wednesday|thursday|friday|saturday|sunday|all] Edit the template autostart requirement weekdays - workspaces created from this template can only autostart on the given weekdays. To unset this value for the template (and allow autostart on all days), pass 'all'. - --autostop-requirement-weekdays string-array + --autostop-requirement-weekdays [monday|tuesday|wednesday|thursday|friday|saturday|sunday|none] Edit the template autostop requirement weekdays - workspaces created from this template must be restarted on the given weekdays. To unset this value for the template (and disable the autostop requirement for diff --git a/cli/testdata/coder_templates_list_--help.golden b/cli/testdata/coder_templates_list_--help.golden index d8bfc63665d10..e3249c556f2ea 100644 --- a/cli/testdata/coder_templates_list_--help.golden +++ b/cli/testdata/coder_templates_list_--help.golden @@ -8,13 +8,11 @@ USAGE: Aliases: ls OPTIONS: - -c, --column string-array (default: name,organization name,last updated,used by) - Columns to display in table output. Available columns: name, created - at, last updated, organization id, organization name, provisioner, - active version id, used by, default ttl. + -c, --column [name|created at|last updated|organization id|organization name|provisioner|active version id|used by|default ttl] (default: name,organization name,last updated,used by) + Columns to display in table output. - -o, --output string (default: table) - Output format. Available formats: table, json. + -o, --output table|json (default: table) + Output format. ——— Run `coder --help` for a list of global options. diff --git a/cli/testdata/coder_templates_versions_list_--help.golden b/cli/testdata/coder_templates_versions_list_--help.golden index 186f15a3ef9f8..52c243c45b435 100644 --- a/cli/testdata/coder_templates_versions_list_--help.golden +++ b/cli/testdata/coder_templates_versions_list_--help.golden @@ -9,15 +9,14 @@ OPTIONS: -O, --org string, $CODER_ORGANIZATION Select which organization (uuid or name) to use. - -c, --column string-array (default: Name,Created At,Created By,Status,Active) - Columns to display in table output. Available columns: name, created - at, created by, status, active, archived. + -c, --column [name|created at|created by|status|active|archived] (default: name,created at,created by,status,active) + Columns to display in table output. --include-archived bool Include archived versions in the result list. - -o, --output string (default: table) - Output format. Available formats: table, json. + -o, --output table|json (default: table) + Output format. ——— Run `coder --help` for a list of global options. diff --git a/cli/testdata/coder_tokens_list_--help.golden b/cli/testdata/coder_tokens_list_--help.golden index 7e52e11c5636b..9ad17fbafb8e6 100644 --- a/cli/testdata/coder_tokens_list_--help.golden +++ b/cli/testdata/coder_tokens_list_--help.golden @@ -12,12 +12,11 @@ OPTIONS: Specifies whether all users' tokens will be listed or not (must have Owner role to see all tokens). - -c, --column string-array (default: id,name,last used,expires at,created at) - Columns to display in table output. Available columns: id, name, last - used, expires at, created at, owner. + -c, --column [id|name|last used|expires at|created at|owner] (default: id,name,last used,expires at,created at) + Columns to display in table output. - -o, --output string (default: table) - Output format. Available formats: table, json. + -o, --output table|json (default: table) + Output format. ——— Run `coder --help` for a list of global options. diff --git a/cli/testdata/coder_users_activate_--help.golden b/cli/testdata/coder_users_activate_--help.golden index 471fdd195d50d..5140638eb80b4 100644 --- a/cli/testdata/coder_users_activate_--help.golden +++ b/cli/testdata/coder_users_activate_--help.golden @@ -11,7 +11,7 @@ USAGE: $ coder users activate example_user OPTIONS: - -c, --column string-array (default: username,email,created_at,status) + -c, --column [username|email|created at|status] (default: username,email,created at,status) Specify a column to filter in the table. ——— diff --git a/cli/testdata/coder_users_list_--help.golden b/cli/testdata/coder_users_list_--help.golden index c2e279af699fa..33d52b1feb498 100644 --- a/cli/testdata/coder_users_list_--help.golden +++ b/cli/testdata/coder_users_list_--help.golden @@ -6,12 +6,11 @@ USAGE: Aliases: ls OPTIONS: - -c, --column string-array (default: username,email,created_at,status) - Columns to display in table output. Available columns: id, username, - email, created at, updated at, status. + -c, --column [id|username|email|created at|updated at|status] (default: username,email,created at,status) + Columns to display in table output. - -o, --output string (default: table) - Output format. Available formats: table, json. + -o, --output table|json (default: table) + Output format. ——— Run `coder --help` for a list of global options. diff --git a/cli/testdata/coder_users_show_--help.golden b/cli/testdata/coder_users_show_--help.golden index 9340c0ac1c973..230d782755bc6 100644 --- a/cli/testdata/coder_users_show_--help.golden +++ b/cli/testdata/coder_users_show_--help.golden @@ -8,8 +8,8 @@ USAGE: $ coder users show me OPTIONS: - -o, --output string (default: table) - Output format. Available formats: table, json. + -o, --output table|json (default: table) + Output format. ——— Run `coder --help` for a list of global options. diff --git a/cli/testdata/coder_users_suspend_--help.golden b/cli/testdata/coder_users_suspend_--help.golden index 8b706e92d6d7a..ebddb77bbb907 100644 --- a/cli/testdata/coder_users_suspend_--help.golden +++ b/cli/testdata/coder_users_suspend_--help.golden @@ -9,7 +9,7 @@ USAGE: $ coder users suspend example_user OPTIONS: - -c, --column string-array (default: username,email,created_at,status) + -c, --column [username|email|created at|status] (default: username,email,created at,status) Specify a column to filter in the table. ——— diff --git a/cli/testdata/coder_version_--help.golden b/cli/testdata/coder_version_--help.golden index ec14e8a6a8222..f8fbadc9a32ae 100644 --- a/cli/testdata/coder_version_--help.golden +++ b/cli/testdata/coder_version_--help.golden @@ -6,8 +6,8 @@ USAGE: Show coder version OPTIONS: - -o, --output string (default: text) - Output format. Available formats: text, json. + -o, --output text|json (default: text) + Output format. ——— Run `coder --help` for a list of global options. diff --git a/cli/userlist.go b/cli/userlist.go index 616126699cc03..ad567868799d7 100644 --- a/cli/userlist.go +++ b/cli/userlist.go @@ -15,7 +15,7 @@ import ( func (r *RootCmd) userList() *serpent.Command { formatter := cliui.NewOutputFormatter( - cliui.TableFormat([]codersdk.User{}, []string{"username", "email", "created_at", "status"}), + cliui.TableFormat([]codersdk.User{}, []string{"username", "email", "created at", "status"}), cliui.JSONFormat(), ) client := new(codersdk.Client) diff --git a/cli/userstatus.go b/cli/userstatus.go index fae2805de710d..600eade3124ce 100644 --- a/cli/userstatus.go +++ b/cli/userstatus.go @@ -36,6 +36,7 @@ func (r *RootCmd) createUserStatusCommand(sdkStatus codersdk.UserStatus) *serpen client := new(codersdk.Client) var columns []string + allColumns := []string{"username", "email", "created at", "status"} cmd := &serpent.Command{ Use: fmt.Sprintf("%s ", verb), Short: short, @@ -99,8 +100,8 @@ func (r *RootCmd) createUserStatusCommand(sdkStatus codersdk.UserStatus) *serpen Flag: "column", FlagShorthand: "c", Description: "Specify a column to filter in the table.", - Default: strings.Join([]string{"username", "email", "created_at", "status"}, ","), - Value: serpent.StringArrayOf(&columns), + Default: strings.Join(allColumns, ","), + Value: serpent.EnumArrayOf(&columns, allColumns...), }, } return cmd diff --git a/codersdk/organizations.go b/codersdk/organizations.go index 05ebadacf3154..a1dc562055f82 100644 --- a/codersdk/organizations.go +++ b/codersdk/organizations.go @@ -42,7 +42,7 @@ func ProvisionerTypeValid[T ProvisionerType | string](pt T) error { type MinimalOrganization struct { ID uuid.UUID `table:"id" json:"id" validate:"required" format:"uuid"` Name string `table:"name,default_sort" json:"name"` - DisplayName string `table:"display_name" json:"display_name"` + DisplayName string `table:"display name" json:"display_name"` Icon string `table:"icon" json:"icon"` } @@ -50,8 +50,8 @@ type MinimalOrganization struct { type Organization struct { MinimalOrganization `table:"m,recursive_inline"` Description string `table:"description" json:"description"` - CreatedAt time.Time `table:"created_at" json:"created_at" validate:"required" format:"date-time"` - UpdatedAt time.Time `table:"updated_at" json:"updated_at" validate:"required" format:"date-time"` + CreatedAt time.Time `table:"created at" json:"created_at" validate:"required" format:"date-time"` + UpdatedAt time.Time `table:"updated at" json:"updated_at" validate:"required" format:"date-time"` IsDefault bool `table:"default" json:"is_default" validate:"required"` } @@ -67,7 +67,7 @@ type OrganizationMember struct { OrganizationID uuid.UUID `table:"organization id" json:"organization_id" format:"uuid"` CreatedAt time.Time `table:"created at" json:"created_at" format:"date-time"` UpdatedAt time.Time `table:"updated at" json:"updated_at" format:"date-time"` - Roles []SlimRole `table:"organization_roles" json:"roles"` + Roles []SlimRole `table:"organization roles" json:"roles"` } type OrganizationMemberWithUserData struct { diff --git a/codersdk/provisionerdaemons.go b/codersdk/provisionerdaemons.go index df481dc04a18d..0dd111ea1b774 100644 --- a/codersdk/provisionerdaemons.go +++ b/codersdk/provisionerdaemons.go @@ -275,8 +275,8 @@ func (c *Client) ServeProvisionerDaemon(ctx context.Context, req ServeProvisione type ProvisionerKey struct { ID uuid.UUID `json:"id" table:"-" format:"uuid"` - CreatedAt time.Time `json:"created_at" table:"created_at" format:"date-time"` - OrganizationID uuid.UUID `json:"organization" table:"organization_id" format:"uuid"` + CreatedAt time.Time `json:"created_at" table:"created at" format:"date-time"` + OrganizationID uuid.UUID `json:"organization" table:"organization id" format:"uuid"` Name string `json:"name" table:"name,default_sort"` Tags map[string]string `json:"tags" table:"tags"` // HashedSecret - never include the access token in the API response diff --git a/codersdk/roles.go b/codersdk/roles.go index 80f866bbfeadb..f248c38798d19 100644 --- a/codersdk/roles.go +++ b/codersdk/roles.go @@ -53,22 +53,22 @@ type Permission struct { // Role is a longer form of SlimRole that includes permissions details. type Role struct { Name string `json:"name" table:"name,default_sort" validate:"username"` - OrganizationID string `json:"organization_id,omitempty" table:"organization_id" format:"uuid"` - DisplayName string `json:"display_name" table:"display_name"` - SitePermissions []Permission `json:"site_permissions" table:"site_permissions"` + OrganizationID string `json:"organization_id,omitempty" table:"organization id" format:"uuid"` + DisplayName string `json:"display_name" table:"display name"` + SitePermissions []Permission `json:"site_permissions" table:"site permissions"` // OrganizationPermissions are specific for the organization in the field 'OrganizationID' above. - OrganizationPermissions []Permission `json:"organization_permissions" table:"organization_permissions"` - UserPermissions []Permission `json:"user_permissions" table:"user_permissions"` + OrganizationPermissions []Permission `json:"organization_permissions" table:"organization permissions"` + UserPermissions []Permission `json:"user_permissions" table:"user permissions"` } // CustomRoleRequest is used to edit custom roles. type CustomRoleRequest struct { Name string `json:"name" table:"name,default_sort" validate:"username"` - DisplayName string `json:"display_name" table:"display_name"` - SitePermissions []Permission `json:"site_permissions" table:"site_permissions"` + DisplayName string `json:"display_name" table:"display name"` + SitePermissions []Permission `json:"site_permissions" table:"site permissions"` // OrganizationPermissions are specific to the organization the role belongs to. - OrganizationPermissions []Permission `json:"organization_permissions" table:"organization_permissions"` - UserPermissions []Permission `json:"user_permissions" table:"user_permissions"` + OrganizationPermissions []Permission `json:"organization_permissions" table:"organization permissions"` + UserPermissions []Permission `json:"user_permissions" table:"user permissions"` } // FullName returns the role name scoped to the organization ID. This is useful if diff --git a/codersdk/templates.go b/codersdk/templates.go index 56b3b3c0483ef..378b64103be93 100644 --- a/codersdk/templates.go +++ b/codersdk/templates.go @@ -118,6 +118,8 @@ func BitmapToWeekdays(bitmap uint8) []string { return days } +var AllDaysOfWeek = []string{"monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"} + type TemplateAutostartRequirement struct { // DaysOfWeek is a list of days of the week in which autostart is allowed // to happen. If no days are specified, autostart is not allowed. diff --git a/codersdk/workspaceproxy.go b/codersdk/workspaceproxy.go index 268486be530cd..37e4c4ee34940 100644 --- a/codersdk/workspaceproxy.go +++ b/codersdk/workspaceproxy.go @@ -32,7 +32,7 @@ type WorkspaceProxyStatus struct { Status ProxyHealthStatus `json:"status" table:"status,default_sort"` // Report provides more information about the health of the workspace proxy. Report ProxyHealthReport `json:"report,omitempty" table:"report"` - CheckedAt time.Time `json:"checked_at" table:"checked_at" format:"date-time"` + CheckedAt time.Time `json:"checked_at" table:"checked at" format:"date-time"` } // ProxyHealthReport is a report of the health of the workspace proxy. @@ -48,16 +48,16 @@ type ProxyHealthReport struct { type WorkspaceProxy struct { // Extends Region with extra information Region `table:"region,recursive_inline"` - DerpEnabled bool `json:"derp_enabled" table:"derp_enabled"` - DerpOnly bool `json:"derp_only" table:"derp_only"` + DerpEnabled bool `json:"derp_enabled" table:"derp enabled"` + DerpOnly bool `json:"derp_only" table:"derp only"` // Status is the latest status check of the proxy. This will be empty for deleted // proxies. This value can be used to determine if a workspace proxy is healthy // and ready to use. Status WorkspaceProxyStatus `json:"status,omitempty" table:"proxy,recursive"` - CreatedAt time.Time `json:"created_at" format:"date-time" table:"created_at"` - UpdatedAt time.Time `json:"updated_at" format:"date-time" table:"updated_at"` + CreatedAt time.Time `json:"created_at" format:"date-time" table:"created at"` + UpdatedAt time.Time `json:"updated_at" format:"date-time" table:"updated at"` Deleted bool `json:"deleted" table:"deleted"` Version string `json:"version" table:"version"` } @@ -187,8 +187,8 @@ type RegionsResponse[R RegionTypes] struct { type Region struct { ID uuid.UUID `json:"id" format:"uuid" table:"id"` Name string `json:"name" table:"name,default_sort"` - DisplayName string `json:"display_name" table:"display_name"` - IconURL string `json:"icon_url" table:"icon_url"` + DisplayName string `json:"display_name" table:"display name"` + IconURL string `json:"icon_url" table:"icon url"` Healthy bool `json:"healthy" table:"healthy"` // PathAppURL is the URL to the base path for path apps. Optional @@ -200,7 +200,7 @@ type Region struct { // E.g. *.us.example.com // E.g. *--suffix.au.example.com // Optional. Does not need to be on the same domain as PathAppURL. - WildcardHostname string `json:"wildcard_hostname" table:"wildcard_hostname"` + WildcardHostname string `json:"wildcard_hostname" table:"wildcard hostname"` } func (c *Client) Regions(ctx context.Context) ([]Region, error) { diff --git a/docs/manifest.json b/docs/manifest.json index 375a20c6cbf1a..91b1ae90efe9e 100644 --- a/docs/manifest.json +++ b/docs/manifest.json @@ -652,6 +652,11 @@ "title": "coder", "path": "reference/cli/README.md" }, + { + "title": "completion", + "description": "Install or update shell completion scripts for the detected or chosen shell.", + "path": "reference/cli/completion.md" + }, { "title": "config-ssh", "description": "Add an SSH Host entry for your workspaces \"ssh coder.workspace\"", diff --git a/docs/reference/cli/README.md b/docs/reference/cli/README.md index 37780bfee1b7b..0b0331afa8273 100644 --- a/docs/reference/cli/README.md +++ b/docs/reference/cli/README.md @@ -25,6 +25,7 @@ Coder — A tool for provisioning self-hosted development environments with Terr | Name | Purpose | | -------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | +| [completion](./completion.md) | Install or update shell completion scripts for the detected or chosen shell. | | [dotfiles](./dotfiles.md) | Personalize your workspace by applying a canonical dotfiles repository | | [external-auth](./external-auth.md) | Manage external authentication | | [login](./login.md) | Authenticate with Coder deployment | diff --git a/docs/reference/cli/completion.md b/docs/reference/cli/completion.md new file mode 100644 index 0000000000000..45e8ab77b741d --- /dev/null +++ b/docs/reference/cli/completion.md @@ -0,0 +1,29 @@ + + +# completion + +Install or update shell completion scripts for the detected or chosen shell. + +## Usage + +```console +coder completion [flags] +``` + +## Options + +### -s, --shell + +| | | +| ---- | ---------------------------------------- | +| Type | bash\|fish\|zsh\|powershell | + +The shell to install completion for. + +### -p, --print + +| | | +| ---- | ----------------- | +| Type | bool | + +Print the completion script instead of installing it. diff --git a/docs/reference/cli/config-ssh.md b/docs/reference/cli/config-ssh.md index 005fcfa42fa99..ef1c75e56ec61 100644 --- a/docs/reference/cli/config-ssh.md +++ b/docs/reference/cli/config-ssh.md @@ -84,7 +84,7 @@ Override the default host prefix. | | | | ----------- | ---------------------------------- | -| Type | enum[yes\|no\|auto] | +| Type | yes\|no\|auto | | Environment | $CODER_CONFIGSSH_WAIT | | Default | auto | diff --git a/docs/reference/cli/features_list.md b/docs/reference/cli/features_list.md index 3cafdcb0ed004..43795aea2874b 100644 --- a/docs/reference/cli/features_list.md +++ b/docs/reference/cli/features_list.md @@ -16,18 +16,18 @@ coder features list [flags] ### -c, --column -| | | -| ------- | -------------------------------------------------- | -| Type | string-array | -| Default | Name,Entitlement,Enabled,Limit,Actual | +| | | +| ------- | -------------------------------------------------------- | +| Type | [name\|entitlement\|enabled\|limit\|actual] | +| Default | name,entitlement,enabled,limit,actual | -Specify a column to filter in the table. Available columns are: Name, Entitlement, Enabled, Limit, Actual. +Specify columns to filter in the table. ### -o, --output -| | | -| ------- | ------------------- | -| Type | string | -| Default | table | +| | | +| ------- | ------------------------ | +| Type | table\|json | +| Default | table | -Output format. Available formats are: table, json. +Output format. diff --git a/docs/reference/cli/groups_list.md b/docs/reference/cli/groups_list.md index 04d9fe726adfd..f3ab2f5e0956e 100644 --- a/docs/reference/cli/groups_list.md +++ b/docs/reference/cli/groups_list.md @@ -14,21 +14,21 @@ coder groups list [flags] ### -c, --column -| | | -| ------- | ----------------------------------------------------------------- | -| Type | string-array | -| Default | name,display name,organization id,members,avatar url | +| | | +| ------- | ----------------------------------------------------------------------- | +| Type | [name\|display name\|organization id\|members\|avatar url] | +| Default | name,display name,organization id,members,avatar url | -Columns to display in table output. Available columns: name, display name, organization id, members, avatar url. +Columns to display in table output. ### -o, --output -| | | -| ------- | ------------------- | -| Type | string | -| Default | table | +| | | +| ------- | ------------------------ | +| Type | table\|json | +| Default | table | -Output format. Available formats: table, json. +Output format. ### -O, --org diff --git a/docs/reference/cli/licenses_list.md b/docs/reference/cli/licenses_list.md index 121f9a4716efe..a888c44331546 100644 --- a/docs/reference/cli/licenses_list.md +++ b/docs/reference/cli/licenses_list.md @@ -18,18 +18,18 @@ coder licenses list [flags] ### -c, --column -| | | -| ------- | ---------------------------------------------------- | -| Type | string-array | -| Default | ID,UUID,Expires At,Uploaded At,Features | +| | | +| ------- | ----------------------------------------------------------------- | +| Type | [id\|uuid\|uploaded at\|features\|expires at\|trial] | +| Default | ID,UUID,Expires At,Uploaded At,Features | -Columns to display in table output. Available columns: id, uuid, uploaded at, features, expires at, trial. +Columns to display in table output. ### -o, --output -| | | -| ------- | ------------------- | -| Type | string | -| Default | table | +| | | +| ------- | ------------------------ | +| Type | table\|json | +| Default | table | -Output format. Available formats: table, json. +Output format. diff --git a/docs/reference/cli/list.md b/docs/reference/cli/list.md index e64adf399dd6a..e9e82988c0af8 100644 --- a/docs/reference/cli/list.md +++ b/docs/reference/cli/list.md @@ -35,18 +35,18 @@ Search for a workspace with a query. ### -c, --column -| | | -| ------- | -------------------------------------------------------------------------------------------------------- | -| Type | string-array | -| Default | workspace,template,status,healthy,last built,current version,outdated,starts at,stops after | +| | | +| ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| Type | [favorite\|workspace\|organization id\|organization name\|template\|status\|healthy\|last built\|current version\|outdated\|starts at\|starts next\|stops after\|stops next\|daily cost] | +| Default | workspace,template,status,healthy,last built,current version,outdated,starts at,stops after | -Columns to display in table output. Available columns: favorite, workspace, organization id, organization name, template, status, healthy, last built, current version, outdated, starts at, starts next, stops after, stops next, daily cost. +Columns to display in table output. ### -o, --output -| | | -| ------- | ------------------- | -| Type | string | -| Default | table | +| | | +| ------- | ------------------------ | +| Type | table\|json | +| Default | table | -Output format. Available formats: table, json. +Output format. diff --git a/docs/reference/cli/schedule_show.md b/docs/reference/cli/schedule_show.md index 8ecf6d59b7ac9..a9f848a242fda 100644 --- a/docs/reference/cli/schedule_show.md +++ b/docs/reference/cli/schedule_show.md @@ -42,18 +42,18 @@ Search for a workspace with a query. ### -c, --column -| | | -| ------- | ------------------------------------------------------------------- | -| Type | string-array | -| Default | workspace,starts at,starts next,stops after,stops next | +| | | +| ------- | ------------------------------------------------------------------------- | +| Type | [workspace\|starts at\|starts next\|stops after\|stops next] | +| Default | workspace,starts at,starts next,stops after,stops next | -Columns to display in table output. Available columns: workspace, starts at, starts next, stops after, stops next. +Columns to display in table output. ### -o, --output -| | | -| ------- | ------------------- | -| Type | string | -| Default | table | +| | | +| ------- | ------------------------ | +| Type | table\|json | +| Default | table | -Output format. Available formats: table, json. +Output format. diff --git a/docs/reference/cli/server.md b/docs/reference/cli/server.md index ae9eea9c8ac63..1ecdd326f1b17 100644 --- a/docs/reference/cli/server.md +++ b/docs/reference/cli/server.md @@ -930,12 +930,12 @@ URL of a PostgreSQL database. If empty, PostgreSQL binaries will be downloaded f ### --postgres-auth -| | | -| ----------- | -------------------------------------- | -| Type | enum[password\|awsiamrds] | -| Environment | $CODER_PG_AUTH | -| YAML | pgAuth | -| Default | password | +| | | +| ----------- | -------------------------------- | +| Type | password\|awsiamrds | +| Environment | $CODER_PG_AUTH | +| YAML | pgAuth | +| Default | password | Type of auth to use when connecting to postgres. diff --git a/docs/reference/cli/server_create-admin-user.md b/docs/reference/cli/server_create-admin-user.md index 18088395b1b66..611d95094c92e 100644 --- a/docs/reference/cli/server_create-admin-user.md +++ b/docs/reference/cli/server_create-admin-user.md @@ -25,7 +25,7 @@ URL of a PostgreSQL database. If empty, the built-in PostgreSQL deployment will | | | | ----------- | -------------------------------------- | -| Type | enum[password\|awsiamrds] | +| Type | password\|awsiamrds | | Environment | $CODER_PG_CONNECTION_AUTH | | Default | password | diff --git a/docs/reference/cli/server_dbcrypt_decrypt.md b/docs/reference/cli/server_dbcrypt_decrypt.md index e6bae7a29c88d..69780471817b1 100644 --- a/docs/reference/cli/server_dbcrypt_decrypt.md +++ b/docs/reference/cli/server_dbcrypt_decrypt.md @@ -25,7 +25,7 @@ The connection URL for the Postgres database. | | | | ----------- | -------------------------------------- | -| Type | enum[password\|awsiamrds] | +| Type | password\|awsiamrds | | Environment | $CODER_PG_CONNECTION_AUTH | | Default | password | diff --git a/docs/reference/cli/server_dbcrypt_delete.md b/docs/reference/cli/server_dbcrypt_delete.md index ff8128f8848c5..e33560d2ae990 100644 --- a/docs/reference/cli/server_dbcrypt_delete.md +++ b/docs/reference/cli/server_dbcrypt_delete.md @@ -29,7 +29,7 @@ The connection URL for the Postgres database. | | | | ----------- | -------------------------------------- | -| Type | enum[password\|awsiamrds] | +| Type | password\|awsiamrds | | Environment | $CODER_PG_CONNECTION_AUTH | | Default | password | diff --git a/docs/reference/cli/server_dbcrypt_rotate.md b/docs/reference/cli/server_dbcrypt_rotate.md index b54903afc75d7..02aaa1451f004 100644 --- a/docs/reference/cli/server_dbcrypt_rotate.md +++ b/docs/reference/cli/server_dbcrypt_rotate.md @@ -25,7 +25,7 @@ The connection URL for the Postgres database. | | | | ----------- | -------------------------------------- | -| Type | enum[password\|awsiamrds] | +| Type | password\|awsiamrds | | Environment | $CODER_PG_CONNECTION_AUTH | | Default | password | diff --git a/docs/reference/cli/speedtest.md b/docs/reference/cli/speedtest.md index ab9d9a4f7e49c..664ac2d3f383e 100644 --- a/docs/reference/cli/speedtest.md +++ b/docs/reference/cli/speedtest.md @@ -22,10 +22,10 @@ Specifies whether to wait for a direct connection before testing speed. ### --direction -| | | -| ------- | --------------------------- | -| Type | enum[up\|down] | -| Default | down | +| | | +| ------- | --------------------- | +| Type | up\|down | +| Default | down | Specifies whether to run in reverse mode where the client receives and the server sends. @@ -48,18 +48,18 @@ Specifies a file to write a network capture to. ### -c, --column -| | | -| ------- | -------------------------------- | -| Type | string-array | -| Default | Interval,Throughput | +| | | +| ------- | ----------------------------------- | +| Type | [Interval\|Throughput] | +| Default | Interval,Throughput | -Columns to display in table output. Available columns: Interval, Throughput. +Columns to display in table output. ### -o, --output -| | | -| ------- | ------------------- | -| Type | string | -| Default | table | +| | | +| ------- | ------------------------ | +| Type | table\|json | +| Default | table | -Output format. Available formats: table, json. +Output format. diff --git a/docs/reference/cli/ssh.md b/docs/reference/cli/ssh.md index d2110628feec4..477c706775e87 100644 --- a/docs/reference/cli/ssh.md +++ b/docs/reference/cli/ssh.md @@ -60,11 +60,11 @@ Specifies how often to poll for workspace automated shutdown. ### --wait -| | | -| ----------- | -------------------------------- | -| Type | enum[yes\|no\|auto] | -| Environment | $CODER_SSH_WAIT | -| Default | auto | +| | | +| ----------- | ---------------------------- | +| Type | yes\|no\|auto | +| Environment | $CODER_SSH_WAIT | +| Default | auto | Specifies whether or not to wait for the startup script to finish executing. Auto means that the agent startup script behavior configured in the workspace template is used. diff --git a/docs/reference/cli/stat.md b/docs/reference/cli/stat.md index 6e0510a805fd4..70da8dee47f7a 100644 --- a/docs/reference/cli/stat.md +++ b/docs/reference/cli/stat.md @@ -22,18 +22,18 @@ coder stat [flags] ### -c, --column -| | | -| ------- | -------------------------------------------------------------------------- | -| Type | string-array | -| Default | host_cpu,host_memory,home_disk,container_cpu,container_memory | +| | | +| ------- | -------------------------------------------------------------------------------- | +| Type | [host cpu\|host memory\|home disk\|container cpu\|container memory] | +| Default | host cpu,host memory,home disk,container cpu,container memory | -Columns to display in table output. Available columns: host cpu, host memory, home disk, container cpu, container memory. +Columns to display in table output. ### -o, --output -| | | -| ------- | ------------------- | -| Type | string | -| Default | table | +| | | +| ------- | ------------------------ | +| Type | table\|json | +| Default | table | -Output format. Available formats: table, json. +Output format. diff --git a/docs/reference/cli/stat_cpu.md b/docs/reference/cli/stat_cpu.md index f86397155d5cc..8e86ef4ddc7f9 100644 --- a/docs/reference/cli/stat_cpu.md +++ b/docs/reference/cli/stat_cpu.md @@ -22,9 +22,9 @@ Force host CPU measurement. ### -o, --output -| | | -| ------- | ------------------- | -| Type | string | -| Default | text | +| | | +| ------- | ----------------------- | +| Type | text\|json | +| Default | text | -Output format. Available formats: text, json. +Output format. diff --git a/docs/reference/cli/stat_disk.md b/docs/reference/cli/stat_disk.md index afd3be9db0a41..6b5ca22ee5750 100644 --- a/docs/reference/cli/stat_disk.md +++ b/docs/reference/cli/stat_disk.md @@ -23,18 +23,18 @@ Path for which to check disk usage. ### --prefix -| | | -| ------- | --------------------------------- | -| Type | enum[Ki\|Mi\|Gi\|Ti] | -| Default | Gi | +| | | +| ------- | --------------------------- | +| Type | Ki\|Mi\|Gi\|Ti | +| Default | Gi | SI Prefix for disk measurement. ### -o, --output -| | | -| ------- | ------------------- | -| Type | string | -| Default | text | +| | | +| ------- | ----------------------- | +| Type | text\|json | +| Default | text | -Output format. Available formats: text, json. +Output format. diff --git a/docs/reference/cli/stat_mem.md b/docs/reference/cli/stat_mem.md index cc2b666425bd2..1f8b85d32e5fd 100644 --- a/docs/reference/cli/stat_mem.md +++ b/docs/reference/cli/stat_mem.md @@ -22,18 +22,18 @@ Force host memory measurement. ### --prefix -| | | -| ------- | --------------------------------- | -| Type | enum[Ki\|Mi\|Gi\|Ti] | -| Default | Gi | +| | | +| ------- | --------------------------- | +| Type | Ki\|Mi\|Gi\|Ti | +| Default | Gi | SI Prefix for memory measurement. ### -o, --output -| | | -| ------- | ------------------- | -| Type | string | -| Default | text | +| | | +| ------- | ----------------------- | +| Type | text\|json | +| Default | text | -Output format. Available formats: text, json. +Output format. diff --git a/docs/reference/cli/templates_edit.md b/docs/reference/cli/templates_edit.md index 0e47a9b9be6bc..ea60830951369 100644 --- a/docs/reference/cli/templates_edit.md +++ b/docs/reference/cli/templates_edit.md @@ -70,17 +70,17 @@ Edit the template activity bump - workspaces created from this template will hav ### --autostart-requirement-weekdays -| | | -| ---- | ------------------------- | -| Type | string-array | +| | | +| ---- | ---------------------------------------------------------------------------------- | +| Type | [monday\|tuesday\|wednesday\|thursday\|friday\|saturday\|sunday\|all] | Edit the template autostart requirement weekdays - workspaces created from this template can only autostart on the given weekdays. To unset this value for the template (and allow autostart on all days), pass 'all'. ### --autostop-requirement-weekdays -| | | -| ---- | ------------------------- | -| Type | string-array | +| | | +| ---- | ----------------------------------------------------------------------------------- | +| Type | [monday\|tuesday\|wednesday\|thursday\|friday\|saturday\|sunday\|none] | Edit the template autostop requirement weekdays - workspaces created from this template must be restarted on the given weekdays. To unset this value for the template (and disable the autostop requirement for the template), pass 'none'. diff --git a/docs/reference/cli/templates_init.md b/docs/reference/cli/templates_init.md index 0e20a7acaada6..d29088a4bde5e 100644 --- a/docs/reference/cli/templates_init.md +++ b/docs/reference/cli/templates_init.md @@ -14,8 +14,8 @@ coder templates init [flags] [directory] ### --id -| | | -| ---- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| Type | enum[aws-devcontainer\|aws-linux\|aws-windows\|azure-linux\|do-linux\|docker\|gcp-devcontainer\|gcp-linux\|gcp-vm-container\|gcp-windows\|kubernetes\|nomad-docker\|scratch] | +| | | +| ---- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| Type | aws-devcontainer\|aws-linux\|aws-windows\|azure-linux\|do-linux\|docker\|gcp-devcontainer\|gcp-linux\|gcp-vm-container\|gcp-windows\|kubernetes\|nomad-docker\|scratch | Specify a given example template by ID. diff --git a/docs/reference/cli/templates_list.md b/docs/reference/cli/templates_list.md index 24eb51fe64e6a..81747abd50d5a 100644 --- a/docs/reference/cli/templates_list.md +++ b/docs/reference/cli/templates_list.md @@ -18,18 +18,18 @@ coder templates list [flags] ### -c, --column -| | | -| ------- | -------------------------------------------------------- | -| Type | string-array | -| Default | name,organization name,last updated,used by | +| | | +| ------- | --------------------------------------------------------------------------------------------------------------------------------------- | +| Type | [name\|created at\|last updated\|organization id\|organization name\|provisioner\|active version id\|used by\|default ttl] | +| Default | name,organization name,last updated,used by | -Columns to display in table output. Available columns: name, created at, last updated, organization id, organization name, provisioner, active version id, used by, default ttl. +Columns to display in table output. ### -o, --output -| | | -| ------- | ------------------- | -| Type | string | -| Default | table | +| | | +| ------- | ------------------------ | +| Type | table\|json | +| Default | table | -Output format. Available formats: table, json. +Output format. diff --git a/docs/reference/cli/templates_versions_list.md b/docs/reference/cli/templates_versions_list.md index ca42bce770515..b19e18abe31e4 100644 --- a/docs/reference/cli/templates_versions_list.md +++ b/docs/reference/cli/templates_versions_list.md @@ -31,18 +31,18 @@ Select which organization (uuid or name) to use. ### -c, --column -| | | -| ------- | ----------------------------------------------------- | -| Type | string-array | -| Default | Name,Created At,Created By,Status,Active | +| | | +| ------- | --------------------------------------------------------------------- | +| Type | [name\|created at\|created by\|status\|active\|archived] | +| Default | name,created at,created by,status,active | -Columns to display in table output. Available columns: name, created at, created by, status, active, archived. +Columns to display in table output. ### -o, --output -| | | -| ------- | ------------------- | -| Type | string | -| Default | table | +| | | +| ------- | ------------------------ | +| Type | table\|json | +| Default | table | -Output format. Available formats: table, json. +Output format. diff --git a/docs/reference/cli/tokens_list.md b/docs/reference/cli/tokens_list.md index 8b47a0d78717f..5b0cdab5f070f 100644 --- a/docs/reference/cli/tokens_list.md +++ b/docs/reference/cli/tokens_list.md @@ -26,18 +26,18 @@ Specifies whether all users' tokens will be listed or not (must have Owner role ### -c, --column -| | | -| ------- | ---------------------------------------------------- | -| Type | string-array | -| Default | id,name,last used,expires at,created at | +| | | +| ------- | ----------------------------------------------------------------- | +| Type | [id\|name\|last used\|expires at\|created at\|owner] | +| Default | id,name,last used,expires at,created at | -Columns to display in table output. Available columns: id, name, last used, expires at, created at, owner. +Columns to display in table output. ### -o, --output -| | | -| ------- | ------------------- | -| Type | string | -| Default | table | +| | | +| ------- | ------------------------ | +| Type | table\|json | +| Default | table | -Output format. Available formats: table, json. +Output format. diff --git a/docs/reference/cli/users_activate.md b/docs/reference/cli/users_activate.md index f5b2d3e8b85ca..fe8022616a9e8 100644 --- a/docs/reference/cli/users_activate.md +++ b/docs/reference/cli/users_activate.md @@ -24,9 +24,9 @@ coder users activate [flags] ### -c, --column -| | | -| ------- | --------------------------------------------- | -| Type | string-array | -| Default | username,email,created_at,status | +| | | +| ------- | -------------------------------------------------- | +| Type | [username\|email\|created at\|status] | +| Default | username,email,created at,status | Specify a column to filter in the table. diff --git a/docs/reference/cli/users_list.md b/docs/reference/cli/users_list.md index 1a7a10b20d057..4405179b61697 100644 --- a/docs/reference/cli/users_list.md +++ b/docs/reference/cli/users_list.md @@ -16,18 +16,18 @@ coder users list [flags] ### -c, --column -| | | -| ------- | --------------------------------------------- | -| Type | string-array | -| Default | username,email,created_at,status | +| | | +| ------- | ------------------------------------------------------------------ | +| Type | [id\|username\|email\|created at\|updated at\|status] | +| Default | username,email,created at,status | -Columns to display in table output. Available columns: id, username, email, created at, updated at, status. +Columns to display in table output. ### -o, --output -| | | -| ------- | ------------------- | -| Type | string | -| Default | table | +| | | +| ------- | ------------------------ | +| Type | table\|json | +| Default | table | -Output format. Available formats: table, json. +Output format. diff --git a/docs/reference/cli/users_show.md b/docs/reference/cli/users_show.md index dc941a9728c8b..44887a7339518 100644 --- a/docs/reference/cli/users_show.md +++ b/docs/reference/cli/users_show.md @@ -20,9 +20,9 @@ coder users show [flags] ### -o, --output -| | | -| ------- | ------------------- | -| Type | string | -| Default | table | +| | | +| ------- | ------------------------ | +| Type | table\|json | +| Default | table | -Output format. Available formats: table, json. +Output format. diff --git a/docs/reference/cli/users_suspend.md b/docs/reference/cli/users_suspend.md index d2980d00a4d62..a4bbc8c7b6f82 100644 --- a/docs/reference/cli/users_suspend.md +++ b/docs/reference/cli/users_suspend.md @@ -20,9 +20,9 @@ coder users suspend [flags] ### -c, --column -| | | -| ------- | --------------------------------------------- | -| Type | string-array | -| Default | username,email,created_at,status | +| | | +| ------- | -------------------------------------------------- | +| Type | [username\|email\|created at\|status] | +| Default | username,email,created at,status | Specify a column to filter in the table. diff --git a/docs/reference/cli/version.md b/docs/reference/cli/version.md index 365b5ac1d47cd..a88652fed6489 100644 --- a/docs/reference/cli/version.md +++ b/docs/reference/cli/version.md @@ -14,9 +14,9 @@ coder version [flags] ### -o, --output -| | | -| ------- | ------------------- | -| Type | string | -| Default | text | +| | | +| ------- | ----------------------- | +| Type | text\|json | +| Default | text | -Output format. Available formats: text, json. +Output format. diff --git a/enterprise/cli/features.go b/enterprise/cli/features.go index e7758121d4b8d..3796156149e54 100644 --- a/enterprise/cli/features.go +++ b/enterprise/cli/features.go @@ -32,7 +32,7 @@ func (r *RootCmd) features() *serpent.Command { func (r *RootCmd) featuresList() *serpent.Command { var ( - featureColumns = []string{"Name", "Entitlement", "Enabled", "Limit", "Actual"} + featureColumns = []string{"name", "entitlement", "enabled", "limit", "actual"} columns []string outputFormat string ) @@ -85,18 +85,16 @@ func (r *RootCmd) featuresList() *serpent.Command { { Flag: "column", FlagShorthand: "c", - Description: fmt.Sprintf("Specify a column to filter in the table. Available columns are: %s.", - strings.Join(featureColumns, ", "), - ), - Default: strings.Join(featureColumns, ","), - Value: serpent.StringArrayOf(&columns), + Description: "Specify columns to filter in the table.", + Default: strings.Join(featureColumns, ","), + Value: serpent.EnumArrayOf(&columns, featureColumns...), }, { Flag: "output", FlagShorthand: "o", - Description: "Output format. Available formats are: table, json.", + Description: "Output format.", Default: "table", - Value: serpent.StringOf(&outputFormat), + Value: serpent.EnumOf(&outputFormat, "table", "json"), }, } diff --git a/enterprise/cli/grouplist.go b/enterprise/cli/grouplist.go index 19040acbdade4..3596fe7fe1c88 100644 --- a/enterprise/cli/grouplist.go +++ b/enterprise/cli/grouplist.go @@ -69,10 +69,10 @@ type groupTableRow struct { // For table output: Name string `json:"-" table:"name,default_sort"` - DisplayName string `json:"-" table:"display_name"` - OrganizationID uuid.UUID `json:"-" table:"organization_id"` + DisplayName string `json:"-" table:"display name"` + OrganizationID uuid.UUID `json:"-" table:"organization id"` Members []string `json:"-" table:"members"` - AvatarURL string `json:"-" table:"avatar_url"` + AvatarURL string `json:"-" table:"avatar url"` } func groupsToRows(groups ...codersdk.Group) []groupTableRow { diff --git a/enterprise/cli/licenses.go b/enterprise/cli/licenses.go index a9743f9132d34..9063af40fcf8f 100644 --- a/enterprise/cli/licenses.go +++ b/enterprise/cli/licenses.go @@ -140,11 +140,11 @@ func (r *RootCmd) licensesList() *serpent.Command { type tableLicense struct { ID int32 `table:"id,default_sort"` UUID uuid.UUID `table:"uuid" format:"uuid"` - UploadedAt time.Time `table:"uploaded_at" format:"date-time"` + UploadedAt time.Time `table:"uploaded at" format:"date-time"` // Features is the formatted string for the license claims. // Used for the table view. Features string `table:"features"` - ExpiresAt time.Time `table:"expires_at" format:"date-time"` + ExpiresAt time.Time `table:"expires at" format:"date-time"` Trial bool `table:"trial"` } diff --git a/enterprise/cli/organizationmembers_test.go b/enterprise/cli/organizationmembers_test.go index ffe536156fcf8..c996f0e734a50 100644 --- a/enterprise/cli/organizationmembers_test.go +++ b/enterprise/cli/organizationmembers_test.go @@ -111,7 +111,7 @@ func TestEnterpriseListOrganizationMembers(t *testing.T) { OrganizationID: owner.OrganizationID, }, rbac.ScopedRoleOrgAdmin(owner.OrganizationID)) - inv, root := clitest.New(t, "organization", "members", "list", "-c", "user_id,username,organization_roles") + inv, root := clitest.New(t, "organization", "members", "list", "-c", "user id,username,organization roles") clitest.SetupConfig(t, client, root) buf := new(bytes.Buffer) diff --git a/enterprise/cli/testdata/coder_features_list_--help.golden b/enterprise/cli/testdata/coder_features_list_--help.golden index 04159afa2b206..1b612c5081d16 100644 --- a/enterprise/cli/testdata/coder_features_list_--help.golden +++ b/enterprise/cli/testdata/coder_features_list_--help.golden @@ -6,12 +6,11 @@ USAGE: Aliases: ls OPTIONS: - -c, --column string-array (default: Name,Entitlement,Enabled,Limit,Actual) - Specify a column to filter in the table. Available columns are: Name, - Entitlement, Enabled, Limit, Actual. + -c, --column [name|entitlement|enabled|limit|actual] (default: name,entitlement,enabled,limit,actual) + Specify columns to filter in the table. - -o, --output string (default: table) - Output format. Available formats are: table, json. + -o, --output table|json (default: table) + Output format. ——— Run `coder --help` for a list of global options. diff --git a/enterprise/cli/testdata/coder_groups_list_--help.golden b/enterprise/cli/testdata/coder_groups_list_--help.golden index 04fede5d19d84..db1d8ffc80d5d 100644 --- a/enterprise/cli/testdata/coder_groups_list_--help.golden +++ b/enterprise/cli/testdata/coder_groups_list_--help.golden @@ -9,12 +9,11 @@ OPTIONS: -O, --org string, $CODER_ORGANIZATION Select which organization (uuid or name) to use. - -c, --column string-array (default: name,display name,organization id,members,avatar url) - Columns to display in table output. Available columns: name, display - name, organization id, members, avatar url. + -c, --column [name|display name|organization id|members|avatar url] (default: name,display name,organization id,members,avatar url) + Columns to display in table output. - -o, --output string (default: table) - Output format. Available formats: table, json. + -o, --output table|json (default: table) + Output format. ——— Run `coder --help` for a list of global options. diff --git a/enterprise/cli/testdata/coder_licenses_list_--help.golden b/enterprise/cli/testdata/coder_licenses_list_--help.golden index 17fdc28dbee8d..fc7c670ad60f2 100644 --- a/enterprise/cli/testdata/coder_licenses_list_--help.golden +++ b/enterprise/cli/testdata/coder_licenses_list_--help.golden @@ -8,12 +8,11 @@ USAGE: Aliases: ls OPTIONS: - -c, --column string-array (default: ID,UUID,Expires At,Uploaded At,Features) - Columns to display in table output. Available columns: id, uuid, - uploaded at, features, expires at, trial. + -c, --column [id|uuid|uploaded at|features|expires at|trial] (default: ID,UUID,Expires At,Uploaded At,Features) + Columns to display in table output. - -o, --output string (default: table) - Output format. Available formats: table, json. + -o, --output table|json (default: table) + Output format. ——— Run `coder --help` for a list of global options. diff --git a/enterprise/cli/workspaceproxy.go b/enterprise/cli/workspaceproxy.go index b44c40314292e..992c37c5cdf35 100644 --- a/enterprise/cli/workspaceproxy.go +++ b/enterprise/cli/workspaceproxy.go @@ -442,7 +442,7 @@ func newUpdateProxyResponseFormatter() *updateProxyResponseFormatter { }), cliui.JSONFormat(), // Table formatter expects a slice, make a slice of one. - cliui.ChangeFormatterData(cliui.TableFormat([]codersdk.UpdateWorkspaceProxyResponse{}, []string{"proxy name", "proxy url", "proxy token"}), + cliui.ChangeFormatterData(cliui.TableFormat([]codersdk.UpdateWorkspaceProxyResponse{}, []string{"name", "url", "proxy token"}), func(data any) (any, error) { response, ok := data.(codersdk.UpdateWorkspaceProxyResponse) if !ok { diff --git a/flake.nix b/flake.nix index 5e21cb8a91daa..374c7fc89ed80 100644 --- a/flake.nix +++ b/flake.nix @@ -117,7 +117,7 @@ name = "coder-${osArch}"; # Updated with ./scripts/update-flake.sh`. # This should be updated whenever go.mod changes! - vendorHash = "sha256-Zsy0MAXHtcB647JbGjVutPlvTEAaohOdEvyS49SQwKs="; + vendorHash = "sha256-6K1Y61RaSXITD0tr6iW8PHGyf82lkgVQOSCs3K8YcsY="; proxyVendor = true; src = ./.; nativeBuildInputs = with pkgs; [ getopt openssl zstd ]; diff --git a/go.mod b/go.mod index a34d3658991ad..d1bbafa713579 100644 --- a/go.mod +++ b/go.mod @@ -171,7 +171,7 @@ require ( go.uber.org/goleak v1.3.1-0.20240429205332-517bace7cc29 go4.org/netipx v0.0.0-20230728180743-ad4cb58a6516 golang.org/x/crypto v0.26.0 - golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 + golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa golang.org/x/mod v0.20.0 golang.org/x/net v0.28.0 golang.org/x/oauth2 v0.22.0 @@ -180,7 +180,7 @@ require ( golang.org/x/term v0.23.0 golang.org/x/text v0.17.0 golang.org/x/tools v0.24.0 - golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 + golang.org/x/xerrors v0.0.0-20240716161551-93cc26a95ae9 google.golang.org/api v0.192.0 google.golang.org/grpc v1.65.0 google.golang.org/protobuf v1.34.2 @@ -196,12 +196,13 @@ require ( require go.uber.org/mock v0.4.0 require ( - github.com/coder/serpent v0.7.0 + github.com/coder/serpent v0.7.1-0.20240815055535-d46fb20fa158 github.com/emersion/go-sasl v0.0.0-20200509203442-7bfe0ed36a21 github.com/emersion/go-smtp v0.21.2 github.com/gomarkdown/markdown v0.0.0-20231222211730-1d6d20845b47 github.com/google/go-github/v61 v61.0.0 github.com/mocktools/go-smtp-mock/v2 v2.3.0 + github.com/natefinch/atomic v1.0.1 ) require ( @@ -216,8 +217,10 @@ require ( github.com/go-jose/go-jose/v4 v4.0.2 // indirect github.com/go-viper/mapstructure/v2 v2.0.0 // indirect github.com/hashicorp/go-retryablehttp v0.7.7 // indirect + github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/moby/docker-image-spec v1.3.1 // indirect - github.com/pion/transport/v2 v2.0.0 // indirect + github.com/pion/transport/v2 v2.2.10 // indirect + github.com/pion/transport/v3 v3.0.7 // indirect github.com/tdewolff/test v1.0.11-0.20240106005702-7de5f7df4739 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0 // indirect ) @@ -340,7 +343,7 @@ require ( github.com/lucasb-eyer/go-colorful v1.2.0 // indirect github.com/mailru/easyjson v0.7.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-runewidth v0.0.15 // indirect + github.com/mattn/go-runewidth v0.0.16 // indirect github.com/mdlayher/genetlink v1.3.2 // indirect github.com/mdlayher/netlink v1.7.2 // indirect github.com/mdlayher/sdnotify v1.0.0 // indirect diff --git a/go.sum b/go.sum index 90bdc16ebb529..ccde33bbf4916 100644 --- a/go.sum +++ b/go.sum @@ -221,8 +221,8 @@ github.com/coder/quartz v0.1.0 h1:cLL+0g5l7xTf6ordRnUMMiZtRE8Sq5LxpghS63vEXrQ= github.com/coder/quartz v0.1.0/go.mod h1:vsiCc+AHViMKH2CQpGIpFgdHIEQsxwm8yCscqKmzbRA= github.com/coder/retry v1.5.1 h1:iWu8YnD8YqHs3XwqrqsjoBTAVqT9ml6z9ViJ2wlMiqc= github.com/coder/retry v1.5.1/go.mod h1:blHMk9vs6LkoRT9ZHyuZo360cufXEhrxqvEzeMtRGoY= -github.com/coder/serpent v0.7.0 h1:zGpD2GlF3lKIVkMjNGKbkip88qzd5r/TRcc30X/SrT0= -github.com/coder/serpent v0.7.0/go.mod h1:REkJ5ZFHQUWFTPLExhXYZ1CaHFjxvGNRlLXLdsI08YA= +github.com/coder/serpent v0.7.1-0.20240815055535-d46fb20fa158 h1:Z+QHBAsvToUfV0UMDnUy8oqdPyrScn5WKV4mx4yNcXY= +github.com/coder/serpent v0.7.1-0.20240815055535-d46fb20fa158/go.mod h1:cZFW6/fP+kE9nd/oRkEHJpG6sXCtQ+AX7WMMEHv0Y3Q= github.com/coder/ssh v0.0.0-20231128192721-70855dedb788 h1:YoUSJ19E8AtuUFVYBpXuOD6a/zVP3rcxezNsoDseTUw= github.com/coder/ssh v0.0.0-20231128192721-70855dedb788/go.mod h1:aGQbuCLyhRLMzZF067xc84Lh7JDs1FKwCmF1Crl9dxQ= github.com/coder/tailscale v1.1.1-0.20240702054557-aa558fbe5374 h1:a5Eg7D5e2oAc0tN56ee4yxtiTo76ztpRlk6geljaZp8= @@ -698,8 +698,8 @@ github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWE github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk= github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= -github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= -github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= +github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU= github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= github.com/mdlayher/genetlink v1.3.2 h1:KdrNKe+CTu+IbZnm/GVUMXSqBBLqcGpRDa0xkQy56gw= @@ -718,6 +718,8 @@ github.com/miekg/dns v1.1.57 h1:Jzi7ApEIzwEPLHWRcafCN9LZSBbqQpxjt/wpgvg7wcM= github.com/miekg/dns v1.1.57/go.mod h1:uqRjCRUuEAA6qsOiJvDd+CFo/vW+y5WR6SNmHE55hZk= github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= +github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= +github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-ps v1.0.0 h1:i6ampVEEF4wQFF+bkYfwYgY+F/uYJDktmvLPf7qIgjc= github.com/mitchellh/go-ps v1.0.0/go.mod h1:J4lOc8z8yJs6vUwklHw2XEIiT4z4C40KtWVN3nvg8Pg= github.com/mitchellh/go-testing-interface v1.14.1 h1:jrgshOhYAUVNMAJiKbEu7EqAwgJJ2JqpQmpLJOu07cU= @@ -754,6 +756,8 @@ github.com/muesli/smartcrop v0.3.0 h1:JTlSkmxWg/oQ1TcLDoypuirdE8Y/jzNirQeLkxpA6O github.com/muesli/smartcrop v0.3.0/go.mod h1:i2fCI/UorTfgEpPPLWiFBv4pye+YAG78RwcQLUkocpI= github.com/muesli/termenv v0.15.3-0.20240618155329-98d742f6907a h1:2MaM6YC3mGu54x+RKAA6JiFFHlHDY1UbkxqppT7wYOg= github.com/muesli/termenv v0.15.3-0.20240618155329-98d742f6907a/go.mod h1:hxSnBBYLK21Vtq/PHd0S2FYCxBXzBua8ov5s1RobyRQ= +github.com/natefinch/atomic v1.0.1 h1:ZPYKxkqQOx3KZ+RsbnP/YsgvxWQPGxjC0oBt2AhwV0A= +github.com/natefinch/atomic v1.0.1/go.mod h1:N/D/ELrljoqDyT3rZrsUmtsuzvHkeB/wWjHV22AZRbM= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/niklasfasching/go-org v1.7.0 h1:vyMdcMWWTe/XmANk19F4k8XGBYg0GQ/gJGMimOjGMek= github.com/niklasfasching/go-org v1.7.0/go.mod h1:WuVm4d45oePiE0eX25GqTDQIt/qPW1T9DGkRscqLW5o= @@ -792,8 +796,11 @@ github.com/philhofer/fwd v1.1.2/go.mod h1:qkPdfjR2SIEbspLqpe1tO4n5yICnr2DY7mqEx2 github.com/pierrec/lz4/v4 v4.1.18 h1:xaKrnTkyoqfh1YItXl56+6KJNVYWlEEPuAQW9xsplYQ= github.com/pierrec/lz4/v4 v4.1.18/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4= github.com/pion/logging v0.2.2/go.mod h1:k0/tDVsRCX2Mb2ZEmTqNa7CWsQPc+YYCB7Q+5pahoms= -github.com/pion/transport/v2 v2.0.0 h1:bsMYyqHCbkvHwj+eNCFBuxtlKndKfyGI2vaQmM3fIE4= github.com/pion/transport/v2 v2.0.0/go.mod h1:HS2MEBJTwD+1ZI2eSXSvHJx/HnzQqRy2/LXxt6eVMHc= +github.com/pion/transport/v2 v2.2.10 h1:ucLBLE8nuxiHfvkFKnkDQRYWYfp8ejf4YBOPfaQpw6Q= +github.com/pion/transport/v2 v2.2.10/go.mod h1:sq1kSLWs+cHW9E+2fJP95QudkzbK7wscs8yYgQToO5E= +github.com/pion/transport/v3 v3.0.7 h1:iRbMH05BzSNwhILHoBoAPxoB9xQgOaJk+591KC9P1o0= +github.com/pion/transport/v3 v3.0.7/go.mod h1:YleKiTZ4vqNxVwh77Z0zytYi7rXHl7j6uPLGhhz9rwo= github.com/pion/udp v0.1.4 h1:OowsTmu1Od3sD6i3fQUJxJn2fEvJO6L1TidgadtbTI8= github.com/pion/udp v0.1.4/go.mod h1:G8LDo56HsFwC24LIcnT4YIDU5qcB6NepqqjP0keL2us= github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ= @@ -950,6 +957,7 @@ github.com/vmihailenco/tagparser v0.1.2 h1:gnjoVuB/kljJ5wICEEOpx98oXMWPLj22G67Vb github.com/vmihailenco/tagparser v0.1.2/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI= github.com/wagslane/go-password-validator v0.3.0 h1:vfxOPzGHkz5S146HDpavl0cw1DSVP061Ry2PX0/ON6I= github.com/wagslane/go-password-validator v0.3.0/go.mod h1:TI1XJ6T5fRdRnHqHt14pvy1tNVnrwe7m3/f1f2fDphQ= +github.com/wlynxg/anet v0.0.3/go.mod h1:eay5PRQr7fIVAMbTbchTnO9gG65Hg/uYGdc7mguHxoA= github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= @@ -1040,12 +1048,13 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= +golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw= golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 h1:LfspQV/FYTatPTr/3HzIcmiUFH7PGP+OQ6mgDYo3yuQ= -golang.org/x/exp v0.0.0-20240222234643-814bf88cf225/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc= +golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa h1:ELnwvuAXPNtPk1TJRuGkI9fDTwym6AYBu0qzT8AcHdI= +golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa/go.mod h1:akd2r19cwCdwSwWeIdzYQGa/EZZyqcOdwWiwj5L5eKQ= golang.org/x/image v0.18.0 h1:jGzIakQa/ZXI1I0Fxvaa9W7yP25TqT6cHIHn+6CqvSQ= golang.org/x/image v0.18.0/go.mod h1:4yyo5vMFQjVjUcVk4jEQcU9MGy/rulF5WvUILseCM2E= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -1079,6 +1088,7 @@ golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= golang.org/x/net v0.3.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= +golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE= golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -1132,6 +1142,7 @@ golang.org/x/sys v0.4.1-0.20230131160137-e7d7f63158de/go.mod h1:oPkhp1MJrh7nUepC golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= @@ -1143,6 +1154,7 @@ golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.3.0/go.mod h1:q750SLmJuPmVoN1blW3UFBPREJfb1KmY3vwxfr+nFDA= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= +golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU= golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= golang.org/x/term v0.23.0 h1:F6D4vR+EHoL9/sWAWgAR1H2DcHr4PareCbAaCo1RpuU= golang.org/x/term v0.23.0/go.mod h1:DgV24QBUrK6jhZXl+20l6UWznPlwAHm1Q1mGHtydmSk= @@ -1155,6 +1167,7 @@ golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= @@ -1179,8 +1192,8 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 h1:+cNy6SZtPcJQH3LJVLOSmiC7MMxXNOb3PU/VUEz+EhU= -golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028/go.mod h1:NDW/Ps6MPRej6fsCIbMTohpP40sJ/P/vI1MoTEGwX90= +golang.org/x/xerrors v0.0.0-20240716161551-93cc26a95ae9 h1:LLhsEBxRTBLuKlQxFBYUOU8xyFgXv6cOTp2HASDlsDk= +golang.org/x/xerrors v0.0.0-20240716161551-93cc26a95ae9/go.mod h1:NDW/Ps6MPRej6fsCIbMTohpP40sJ/P/vI1MoTEGwX90= golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 h1:B82qJJgjvYKsXS9jeunTOisW56dUokqW/FOteYJJ/yg= golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2/go.mod h1:deeaetjYA+DHMHg+sMSMI58GrEteJUUzzw7en6TJQcI= golang.zx2c4.com/wireguard/wgctrl v0.0.0-20230429144221-925a1e7659e6 h1:CawjfCvYQH2OU3/TnxLx97WDSUDRABfT18pCOYwc2GE= diff --git a/scripts/clidocgen/command.tpl b/scripts/clidocgen/command.tpl index 29d7ba8b69d4b..39065392f72d0 100644 --- a/scripts/clidocgen/command.tpl +++ b/scripts/clidocgen/command.tpl @@ -43,7 +43,7 @@ Aliases: ### {{ with $opt.FlagShorthand}}-{{ . }}, {{end}}--{{ $opt.Flag }} {{" "}} {{ tableHeader }} -| Type | {{ $opt.Value.Type | wrapCode }} | +| Type | {{ typeHelper $opt | wrapCode }} | {{- with $opt.Env }} | Environment | {{ (print "$" .) | wrapCode }} | {{- end }} diff --git a/scripts/clidocgen/gen.go b/scripts/clidocgen/gen.go index 04f69afe663cd..121ff917e09d2 100644 --- a/scripts/clidocgen/gen.go +++ b/scripts/clidocgen/gen.go @@ -62,6 +62,16 @@ func init() { return `| | | | --- | --- |` }, + "typeHelper": func(opt *serpent.Option) string { + switch v := opt.Value.(type) { + case *serpent.Enum: + return strings.Join(v.Choices, "\\|") + case *serpent.EnumArray: + return fmt.Sprintf("[%s]", strings.Join(v.Choices, "\\|")) + default: + return v.Type() + } + }, }, ).Parse(strings.TrimSpace(commandTemplateRaw)), )