Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Commit cd50b33

Browse files
authored
Unhide rebuild and watch-build subcommands (#161)
1 parent cb3ac49 commit cd50b33

File tree

5 files changed

+79
-11
lines changed

5 files changed

+79
-11
lines changed

docs/coder_envs.md

+2
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,7 @@ Perform operations on the Coder environments owned by the active user.
2323

2424
* [coder](coder.md) - coder provides a CLI for working with an existing Coder Enterprise installation
2525
* [coder envs ls](coder_envs_ls.md) - list all environments owned by the active user
26+
* [coder envs rebuild](coder_envs_rebuild.md) - rebuild a Coder environment
2627
* [coder envs stop](coder_envs_stop.md) - stop Coder environments by name
28+
* [coder envs watch-build](coder_envs_watch-build.md) - trail the build log of a Coder environment
2729

docs/coder_envs_rebuild.md

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
## coder envs rebuild
2+
3+
rebuild a Coder environment
4+
5+
```
6+
coder envs rebuild [environment_name] [flags]
7+
```
8+
9+
### Examples
10+
11+
```
12+
coder envs rebuild front-end-env --follow
13+
coder envs rebuild backend-env --force
14+
```
15+
16+
### Options
17+
18+
```
19+
--follow follow build log after initiating rebuild
20+
--force force rebuild without showing a confirmation prompt
21+
-h, --help help for rebuild
22+
```
23+
24+
### Options inherited from parent commands
25+
26+
```
27+
--user string Specify the user whose resources to target (default "me")
28+
-v, --verbose show verbose output
29+
```
30+
31+
### SEE ALSO
32+
33+
* [coder envs](coder_envs.md) - Interact with Coder environments
34+

docs/coder_envs_watch-build.md

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
## coder envs watch-build
2+
3+
trail the build log of a Coder environment
4+
5+
```
6+
coder envs watch-build [environment_name] [flags]
7+
```
8+
9+
### Examples
10+
11+
```
12+
coder envs watch-build front-end-env
13+
```
14+
15+
### Options
16+
17+
```
18+
-h, --help help for watch-build
19+
```
20+
21+
### Options inherited from parent commands
22+
23+
```
24+
--user string Specify the user whose resources to target (default "me")
25+
-v, --verbose show verbose output
26+
```
27+
28+
### SEE ALSO
29+
30+
* [coder envs](coder_envs.md) - Interact with Coder environments
31+

internal/cmd/envs.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ func envsCommand() *cobra.Command {
3030
lsEnvsCommand(&user),
3131
stopEnvsCommand(&user),
3232
rmEnvsCommand(&user),
33-
watchBuildLogCommand(),
34-
rebuildEnvCommand(),
33+
watchBuildLogCommand(&user),
34+
rebuildEnvCommand(&user),
3535
createEnvCommand(&user),
3636
editEnvCommand(&user),
3737
)

internal/cmd/rebuild.go

+10-9
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
"golang.org/x/xerrors"
1818
)
1919

20-
func rebuildEnvCommand() *cobra.Command {
20+
func rebuildEnvCommand(user *string) *cobra.Command {
2121
var follow bool
2222
var force bool
2323
cmd := &cobra.Command{
@@ -26,14 +26,13 @@ func rebuildEnvCommand() *cobra.Command {
2626
Args: cobra.ExactArgs(1),
2727
Example: `coder envs rebuild front-end-env --follow
2828
coder envs rebuild backend-env --force`,
29-
Hidden: true, // TODO(@cmoog) un-hide
3029
RunE: func(cmd *cobra.Command, args []string) error {
3130
ctx := cmd.Context()
3231
client, err := newClient()
3332
if err != nil {
3433
return err
3534
}
36-
env, err := findEnv(ctx, client, args[0], coder.Me)
35+
env, err := findEnv(ctx, client, args[0], *user)
3736
if err != nil {
3837
return err
3938
}
@@ -44,7 +43,10 @@ coder envs rebuild backend-env --force`,
4443
IsConfirm: true,
4544
}).Run()
4645
if err != nil {
47-
return err
46+
return clog.Fatal(
47+
"failed to confirm prompt", clog.BlankLine,
48+
clog.Tipf(`use "--force" to rebuild without a confirmation prompt`),
49+
)
4850
}
4951
}
5052

@@ -65,7 +67,7 @@ coder envs rebuild backend-env --force`,
6567
},
6668
}
6769

68-
cmd.Flags().BoolVar(&follow, "follow", false, "follow buildlog after initiating rebuild")
70+
cmd.Flags().BoolVar(&follow, "follow", false, "follow build log after initiating rebuild")
6971
cmd.Flags().BoolVar(&force, "force", false, "force rebuild without showing a confirmation prompt")
7072
return cmd
7173
}
@@ -134,20 +136,19 @@ func trailBuildLogs(ctx context.Context, client *coder.Client, envID string) err
134136
return nil
135137
}
136138

137-
func watchBuildLogCommand() *cobra.Command {
139+
func watchBuildLogCommand(user *string) *cobra.Command {
138140
cmd := &cobra.Command{
139141
Use: "watch-build [environment_name]",
140-
Example: "coder watch-build front-end-env",
142+
Example: "coder envs watch-build front-end-env",
141143
Short: "trail the build log of a Coder environment",
142144
Args: cobra.ExactArgs(1),
143-
Hidden: true, // TODO(@cmoog) un-hide
144145
RunE: func(cmd *cobra.Command, args []string) error {
145146
ctx := cmd.Context()
146147
client, err := newClient()
147148
if err != nil {
148149
return err
149150
}
150-
env, err := findEnv(ctx, client, args[0], coder.Me)
151+
env, err := findEnv(ctx, client, args[0], *user)
151152
if err != nil {
152153
return err
153154
}

0 commit comments

Comments
 (0)