Skip to content

Commit 2a2de29

Browse files
committed
Update golden files
1 parent 7c09da2 commit 2a2de29

8 files changed

+89
-9
lines changed

cli/templateversions.go

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"time"
77

88
"github.com/coder/pretty"
9-
109
"github.com/google/uuid"
1110
"golang.org/x/xerrors"
1211

@@ -40,8 +39,15 @@ func (r *RootCmd) templateVersions() *clibase.Cmd {
4039
}
4140

4241
func (r *RootCmd) templateVersionsList() *clibase.Cmd {
42+
defaultColumns := []string{
43+
"Name",
44+
"Created At",
45+
"Created By",
46+
"Status",
47+
"Active",
48+
}
4349
formatter := cliui.NewOutputFormatter(
44-
cliui.TableFormat([]templateVersionRow{}, nil),
50+
cliui.TableFormat([]templateVersionRow{}, defaultColumns),
4551
cliui.JSONFormat(),
4652
)
4753
client := new(codersdk.Client)
@@ -53,6 +59,29 @@ func (r *RootCmd) templateVersionsList() *clibase.Cmd {
5359
Middleware: clibase.Chain(
5460
clibase.RequireNArgs(1),
5561
r.InitClient(client),
62+
func(next clibase.HandlerFunc) clibase.HandlerFunc {
63+
return func(i *clibase.Invocation) error {
64+
// This is the only way to dynamically add the "archived"
65+
// column if '--include-archived' is true.
66+
// It does not make sense to show this column if the
67+
// flag is false.
68+
if includeArchived {
69+
for _, opt := range i.Command.Options {
70+
if opt.Flag == "column" {
71+
if opt.ValueSource == clibase.ValueSourceDefault {
72+
v, ok := opt.Value.(*clibase.StringArray)
73+
if ok {
74+
// Add the extra new default column.
75+
*v = append(*v, "Archived")
76+
}
77+
}
78+
break
79+
}
80+
}
81+
}
82+
return next(i)
83+
}
84+
},
5685
),
5786
Short: "List all the versions of the specified template",
5887
Options: clibase.OptionSet{

cli/testdata/coder_templates_--help.golden

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ USAGE:
2323
$ coder templates push my-template
2424

2525
SUBCOMMANDS:
26+
archive Archive unused failed template versions from a given template(s)
2627
create Create a template from the current directory or as specified by
2728
flag
2829
delete Delete templates
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
coder v0.0.0-devel
2+
3+
USAGE:
4+
coder templates archive [flags] [template-name...]
5+
6+
Archive unused failed template versions from a given template(s)
7+
8+
OPTIONS:
9+
--all bool
10+
Include all unused template versions. By default, only failed template
11+
versions are archived.
12+
13+
-y, --yes bool
14+
Bypass prompts.
15+
16+
———
17+
Run `coder --help` for a list of global options.

cli/testdata/coder_templates_versions_--help.golden

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ USAGE:
1212
$ coder templates versions list my-template
1313

1414
SUBCOMMANDS:
15-
list List all the versions of the specified template
15+
archive Archive a template version(s).
16+
list List all the versions of the specified template
17+
unarchive Unarchive a template version(s).
1618

1719
———
1820
Run `coder --help` for a list of global options.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
coder v0.0.0-devel
2+
3+
USAGE:
4+
coder templates versions archive [flags] <template-name>
5+
[template-version-names...]
6+
7+
Archive a template version(s).
8+
9+
OPTIONS:
10+
-y, --yes bool
11+
Bypass prompts.
12+
13+
———
14+
Run `coder --help` for a list of global options.

cli/testdata/coder_templates_versions_list_--help.golden

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@ USAGE:
66
List all the versions of the specified template
77

88
OPTIONS:
9-
-c, --column string-array (default: name,created at,created by,status,active)
9+
-c, --column string-array (default: Name,Created At,Created By,Status,Active)
1010
Columns to display in table output. Available columns: name, created
11-
at, created by, status, active.
11+
at, created by, status, active, archived.
12+
13+
--include-archived bool
14+
Include archived versions in the result list.
1215

1316
-o, --output string (default: table)
1417
Output format. Available formats: table, json.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
coder v0.0.0-devel
2+
3+
USAGE:
4+
coder templates versions unarchive [flags] <template-name>
5+
[template-version-names...]
6+
7+
Unarchive a template version(s).
8+
9+
OPTIONS:
10+
-y, --yes bool
11+
Bypass prompts.
12+
13+
———
14+
Run `coder --help` for a list of global options.

docs/cli/templates_versions_list.md

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)