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

Commit 03d2d8b

Browse files
authored
Unhide coder envs rm command (#162)
1 parent cd50b33 commit 03d2d8b

File tree

5 files changed

+39
-23
lines changed

5 files changed

+39
-23
lines changed

docs/coder_envs.md

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Perform operations on the Coder environments owned by the active user.
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
2626
* [coder envs rebuild](coder_envs_rebuild.md) - rebuild a Coder environment
27+
* [coder envs rm](coder_envs_rm.md) - remove Coder environments by name
2728
* [coder envs stop](coder_envs_stop.md) - stop Coder environments by name
2829
* [coder envs watch-build](coder_envs_watch-build.md) - trail the build log of a Coder environment
2930

docs/coder_envs_rm.md

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
## coder envs rm
2+
3+
remove Coder environments by name
4+
5+
```
6+
coder envs rm [...environment_names] [flags]
7+
```
8+
9+
### Options
10+
11+
```
12+
-f, --force force remove the specified environments without prompting first
13+
-h, --help help for rm
14+
```
15+
16+
### Options inherited from parent commands
17+
18+
```
19+
--user string Specify the user whose resources to target (default "me")
20+
-v, --verbose show verbose output
21+
```
22+
23+
### SEE ALSO
24+
25+
* [coder envs](coder_envs.md) - Interact with Coder environments
26+

internal/clog/error.go

-13
Original file line numberDiff line numberDiff line change
@@ -78,19 +78,6 @@ func LogWarn(header string, lines ...string) {
7878
}.String())
7979
}
8080

81-
// Warn creates an error with the level "warning".
82-
func Warn(header string, lines ...string) CLIError {
83-
return CLIError{
84-
CLIMessage: CLIMessage{
85-
Color: color.FgYellow,
86-
Level: "warning",
87-
Header: header,
88-
Lines: lines,
89-
},
90-
error: errors.New(header),
91-
}
92-
}
93-
9481
// Error creates an error with the level "error".
9582
func Error(header string, lines ...string) CLIError {
9683
return CLIError{

internal/cmd/auth.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func newClient() (*coder.Client, error) {
3333

3434
u, err := url.Parse(rawURL)
3535
if err != nil {
36-
return nil, xerrors.Errorf("url misformatted: %w try runing \"coder login\" with a valid URL", err)
36+
return nil, xerrors.Errorf("url malformed: %w try runing \"coder login\" with a valid URL", err)
3737
}
3838

3939
c := &coder.Client{
@@ -54,12 +54,12 @@ func newClient() (*coder.Client, error) {
5454
}
5555

5656
if !version.VersionsMatch(apiVersion) {
57-
clog.Log(clog.Warn(
57+
clog.LogWarn(
5858
"version mismatch detected",
5959
fmt.Sprintf("coder-cli version: %s", version.Version),
6060
fmt.Sprintf("Coder API version: %s", apiVersion), clog.BlankLine,
6161
clog.Tipf("download the appropriate version here: https://github.com/cdr/coder-cli/releases"),
62-
))
62+
)
6363
}
6464

6565
return c, nil

internal/cmd/envs.go

+9-7
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,8 @@ coder envs edit back-end-env --disk 20`,
326326
},
327327
}
328328
cmd.Flags().StringVarP(&org, "org", "o", "", "name of the organization the environment should be created under.")
329-
cmd.Flags().StringVarP(&img, "image", "i", "", "name of the image you wan't the environment to be based off of.")
330-
cmd.Flags().StringVarP(&tag, "tag", "t", "latest", "image tag of the image you wan't to base the environment off of.")
329+
cmd.Flags().StringVarP(&img, "image", "i", "", "name of the image you want the environment to be based off of.")
330+
cmd.Flags().StringVarP(&tag, "tag", "t", "latest", "image tag of the image you want to base the environment off of.")
331331
cmd.Flags().Float32P("cpu", "c", cpuCores, "The number of cpu cores the environment should be provisioned with.")
332332
cmd.Flags().Float32P("memory", "m", memGB, "The amount of RAM an environment should be provisioned with.")
333333
cmd.Flags().IntP("disk", "d", diskGB, "The amount of disk storage an environment should be provisioned with.")
@@ -339,10 +339,9 @@ coder envs edit back-end-env --disk 20`,
339339
func rmEnvsCommand(user *string) *cobra.Command {
340340
var force bool
341341
cmd := &cobra.Command{
342-
Use: "rm [...environment_names]",
343-
Short: "remove Coder environments by name",
344-
Hidden: true,
345-
Args: cobra.MinimumNArgs(1),
342+
Use: "rm [...environment_names]",
343+
Short: "remove Coder environments by name",
344+
Args: cobra.MinimumNArgs(1),
346345
RunE: func(cmd *cobra.Command, args []string) error {
347346
ctx := cmd.Context()
348347
client, err := newClient()
@@ -355,7 +354,10 @@ func rmEnvsCommand(user *string) *cobra.Command {
355354
IsConfirm: true,
356355
}
357356
if _, err := confirm.Run(); err != nil {
358-
return err
357+
return clog.Fatal(
358+
"failed to confirm prompt", clog.BlankLine,
359+
clog.Tipf(`use "--force" to rebuild without a confirmation prompt`),
360+
)
359361
}
360362
}
361363

0 commit comments

Comments
 (0)