Skip to content

Commit ea93a04

Browse files
rowansmithauclaude
andcommitted
fix: Format code and update generated documentation for builds and logs CLI commands
Formatted code according to project standards and updated CLI documentation for the workspace build logs feature. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 0317665 commit ea93a04

File tree

10 files changed

+121
-83
lines changed

10 files changed

+121
-83
lines changed

cli/builds.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,12 @@ func (r *RootCmd) builds() *serpent.Command {
5454
}
5555

5656
func (r *RootCmd) buildsList() *serpent.Command {
57-
var (
58-
formatter = cliui.NewOutputFormatter(
59-
cliui.TableFormat(
60-
[]workspaceBuildListRow{},
61-
[]string{"build", "build id", "status", "reason", "created", "duration"},
62-
),
63-
cliui.JSONFormat(),
64-
)
57+
formatter := cliui.NewOutputFormatter(
58+
cliui.TableFormat(
59+
[]workspaceBuildListRow{},
60+
[]string{"build", "build id", "status", "reason", "created", "duration"},
61+
),
62+
cliui.JSONFormat(),
6563
)
6664
client := new(codersdk.Client)
6765
cmd := &serpent.Command{

cli/builds_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ import (
2020

2121
func TestBuildsList(t *testing.T) {
2222
t.Parallel()
23-
23+
2424
t.Run("Table", func(t *testing.T) {
2525
t.Parallel()
2626
client, db := coderdtest.NewWithDatabase(t, nil)
2727
owner := coderdtest.CreateFirstUser(t, client)
2828
member, memberUser := coderdtest.CreateAnotherUser(t, client, owner.OrganizationID)
29-
29+
3030
// Create a workspace with a build
3131
r := dbfake.WorkspaceBuild(t, db, database.WorkspaceTable{
3232
OrganizationID: owner.OrganizationID,
@@ -39,16 +39,16 @@ func TestBuildsList(t *testing.T) {
3939

4040
ctx, cancelFunc := context.WithTimeout(context.Background(), testutil.WaitLong)
4141
defer cancelFunc()
42-
42+
4343
done := make(chan any)
4444
go func() {
4545
errC := inv.WithContext(ctx).Run()
4646
assert.NoError(t, errC)
4747
close(done)
4848
}()
49-
50-
pty.ExpectMatch("1") // Build number
51-
pty.ExpectMatch(r.Build.ID.String()) // Build ID
49+
50+
pty.ExpectMatch("1") // Build number
51+
pty.ExpectMatch(r.Build.ID.String()) // Build ID
5252
cancelFunc()
5353
<-done
5454
})
@@ -58,7 +58,7 @@ func TestBuildsList(t *testing.T) {
5858
client, db := coderdtest.NewWithDatabase(t, nil)
5959
owner := coderdtest.CreateFirstUser(t, client)
6060
member, memberUser := coderdtest.CreateAnotherUser(t, client, owner.OrganizationID)
61-
61+
6262
// Create a workspace with a build
6363
r := dbfake.WorkspaceBuild(t, db, database.WorkspaceTable{
6464
OrganizationID: owner.OrganizationID,
@@ -81,7 +81,7 @@ func TestBuildsList(t *testing.T) {
8181
require.Len(t, builds, 1)
8282
assert.Equal(t, r.Build.ID, builds[0].ID)
8383
})
84-
84+
8585
t.Run("WorkspaceNotFound", func(t *testing.T) {
8686
t.Parallel()
8787
client := coderdtest.New(t, nil)
@@ -98,4 +98,4 @@ func TestBuildsList(t *testing.T) {
9898
require.Error(t, err)
9999
assert.Contains(t, err.Error(), "get workspace")
100100
})
101-
}
101+
}

cli/logs_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ import (
1616

1717
func TestLogs(t *testing.T) {
1818
t.Parallel()
19-
19+
2020
t.Run("LogsInvalidBuildID", func(t *testing.T) {
2121
t.Parallel()
22-
22+
2323
client := coderdtest.New(t, nil)
2424
_ = coderdtest.CreateFirstUser(t, client)
2525

@@ -36,7 +36,7 @@ func TestLogs(t *testing.T) {
3636

3737
t.Run("LogsNonexistentBuild", func(t *testing.T) {
3838
t.Parallel()
39-
39+
4040
client := coderdtest.New(t, nil)
4141
_ = coderdtest.CreateFirstUser(t, client)
4242

@@ -50,4 +50,4 @@ func TestLogs(t *testing.T) {
5050
require.Error(t, err)
5151
assert.True(t, strings.Contains(err.Error(), "get build logs"))
5252
})
53-
}
53+
}

cli/testdata/coder_--help.golden

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ USAGE:
1515

1616
SUBCOMMANDS:
1717
autoupdate Toggle auto-update policy for a workspace
18+
builds Manage workspace builds
1819
completion Install or update shell completion scripts for the
1920
detected or chosen shell.
2021
config-ssh Add an SSH Host entry for your workspaces "ssh
@@ -28,6 +29,7 @@ SUBCOMMANDS:
2829
list List workspaces
2930
login Authenticate with Coder deployment
3031
logout Unauthenticate your local session
32+
logs Show logs for a workspace build
3133
netcheck Print network debug information for DERP and STUN
3234
notifications Manage Coder notifications
3335
open Open a workspace
Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,12 @@
1-
Manage workspace builds
1+
coder v0.0.0-devel
22

3-
Usage:
4-
coder builds [flags] <subcommand>
3+
USAGE:
4+
coder builds
55

6-
Available Commands:
7-
list List builds for a workspace
6+
Manage workspace builds
87

9-
Flags:
10-
--debug-options Print all options, how they're set, then exit.
11-
-h, --help Help for "builds"
8+
SUBCOMMANDS:
9+
list List builds for a workspace
1210

13-
Global Flags:
14-
--header=key=value Additional HTTP headers added to all requests. Provide as key=value. Can be specified multiple times.
15-
--header-command=string An external command that outputs additional HTTP headers added to all requests. The command must output each header as key=value on its own line.
16-
-v, --verbose Enable verbose output.
17-
--no-version-warning Suppress warning when client and server versions do not match.
18-
--no-feature-warning Suppress warnings about unlicensed features.
19-
--url=string URL to a deployment.
20-
--token=string Specify an authentication token. For security reasons setting CODER_SESSION_TOKEN is preferred.
21-
--config-dir=/home/coder/.config/coderv2 Path to the global coder config directory.
22-
--disable-direct-connections Disable direct (P2P) connections to workspaces.
23-
--disable-network-telemetry Disable network telemetry. Network telemetry is collected when connecting to workspaces using the CLI, and is forwarded to the server. If telemetry is also enabled on the server, it may be sent to Coder. Network telemetry is used to measure network quality and detect regressions.
24-
--force-tty Force the use of a TTY.
11+
———
12+
Run `coder --help` for a list of global options.
Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,18 @@
1-
List builds for a workspace
1+
coder v0.0.0-devel
22

3-
Usage:
3+
USAGE:
44
coder builds list [flags] <workspace>
55

6-
Aliases:
7-
list, ls
6+
List builds for a workspace
87

9-
Flags:
10-
--column=string Specify a column to sort by.
11-
-h, --help Help for "list"
12-
--output=table Output format. Available formats are: table, json.
13-
--search=string Filter data by search query.
14-
--sort-by=default_sort Sort builds by the specified column (default "build").
15-
--sort-desc Sort by descending order.
8+
Aliases: ls
169

17-
Global Flags:
18-
--debug-options Print all options, how they're set, then exit.
19-
--header=key=value Additional HTTP headers added to all requests. Provide as key=value. Can be specified multiple times.
20-
--header-command=string An external command that outputs additional HTTP headers added to all requests. The command must output each header as key=value on its own line.
21-
-v, --verbose Enable verbose output.
22-
--no-version-warning Suppress warning when client and server versions do not match.
23-
--no-feature-warning Suppress warnings about unlicensed features.
24-
--url=string URL to a deployment.
25-
--token=string Specify an authentication token. For security reasons setting CODER_SESSION_TOKEN is preferred.
26-
--config-dir=/home/coder/.config/coderv2 Path to the global coder config directory.
27-
--disable-direct-connections Disable direct (P2P) connections to workspaces.
28-
--disable-network-telemetry Disable network telemetry. Network telemetry is collected when connecting to workspaces using the CLI, and is forwarded to the server. If telemetry is also enabled on the server, it may be sent to Coder. Network telemetry is used to measure network quality and detect regressions.
29-
--force-tty Force the use of a TTY.
10+
OPTIONS:
11+
-c, --column [build|build id|status|reason|created|duration] (default: build,build id,status,reason,created,duration)
12+
Columns to display in table output.
13+
14+
-o, --output table|json (default: table)
15+
Output format.
16+
17+
———
18+
Run `coder --help` for a list of global options.

cli/testdata/coder_logs_--help.golden

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,13 @@
1-
Show logs for a workspace build
1+
coder v0.0.0-devel
22

3-
Usage:
3+
USAGE:
44
coder logs [flags] <build-id>
55

6-
Flags:
7-
-f, --follow Follow log output (stream real-time logs).
8-
-h, --help Help for "logs"
6+
Show logs for a workspace build
97

10-
Global Flags:
11-
--debug-options Print all options, how they're set, then exit.
12-
--header=key=value Additional HTTP headers added to all requests. Provide as key=value. Can be specified multiple times.
13-
--header-command=string An external command that outputs additional HTTP headers added to all requests. The command must output each header as key=value on its own line.
14-
-v, --verbose Enable verbose output.
15-
--no-version-warning Suppress warning when client and server versions do not match.
16-
--no-feature-warning Suppress warnings about unlicensed features.
17-
--url=string URL to a deployment.
18-
--token=string Specify an authentication token. For security reasons setting CODER_SESSION_TOKEN is preferred.
19-
--config-dir=/home/coder/.config/coderv2 Path to the global coder config directory.
20-
--disable-direct-connections Disable direct (P2P) connections to workspaces.
21-
--disable-network-telemetry Disable network telemetry. Network telemetry is collected when connecting to workspaces using the CLI, and is forwarded to the server. If telemetry is also enabled on the server, it may be sent to Coder. Network telemetry is used to measure network quality and detect regressions.
22-
--force-tty Force the use of a TTY.
8+
OPTIONS:
9+
-f, --follow bool
10+
Follow log output (stream real-time logs).
11+
12+
———
13+
Run `coder --help` for a list of global options.

docs/reference/cli/builds.md

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

docs/reference/cli/builds_list.md

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

docs/reference/cli/logs.md

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

0 commit comments

Comments
 (0)