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

Unhide coder envs rm command #162

Merged
merged 2 commits into from
Oct 29, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Unhide coder envs rm command
  • Loading branch information
cmoog committed Oct 29, 2020
commit a7d03208f8b88cf8eb4769f4ae6098400fb83271
13 changes: 0 additions & 13 deletions internal/clog/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,6 @@ func LogWarn(header string, lines ...string) {
}.String())
}

// Warn creates an error with the level "warning".
func Warn(header string, lines ...string) CLIError {
return CLIError{
CLIMessage: CLIMessage{
Color: color.FgYellow,
Level: "warning",
Header: header,
Lines: lines,
},
error: errors.New(header),
}
}

// Error creates an error with the level "error".
func Error(header string, lines ...string) CLIError {
return CLIError{
Expand Down
6 changes: 3 additions & 3 deletions internal/cmd/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func newClient() (*coder.Client, error) {

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

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

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

return c, nil
Expand Down
16 changes: 9 additions & 7 deletions internal/cmd/envs.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,8 @@ coder envs edit back-end-env --disk 20`,
},
}
cmd.Flags().StringVarP(&org, "org", "o", "", "name of the organization the environment should be created under.")
cmd.Flags().StringVarP(&img, "image", "i", "", "name of the image you wan't the environment to be based off of.")
cmd.Flags().StringVarP(&tag, "tag", "t", "latest", "image tag of the image you wan't to base the environment off of.")
cmd.Flags().StringVarP(&img, "image", "i", "", "name of the image you want the environment to be based off of.")
cmd.Flags().StringVarP(&tag, "tag", "t", "latest", "image tag of the image you want to base the environment off of.")
cmd.Flags().Float32P("cpu", "c", cpuCores, "The number of cpu cores the environment should be provisioned with.")
cmd.Flags().Float32P("memory", "m", memGB, "The amount of RAM an environment should be provisioned with.")
cmd.Flags().IntP("disk", "d", diskGB, "The amount of disk storage an environment should be provisioned with.")
Expand All @@ -339,10 +339,9 @@ coder envs edit back-end-env --disk 20`,
func rmEnvsCommand(user *string) *cobra.Command {
var force bool
cmd := &cobra.Command{
Use: "rm [...environment_names]",
Short: "remove Coder environments by name",
Hidden: true,
Args: cobra.MinimumNArgs(1),
Use: "rm [...environment_names]",
Short: "remove Coder environments by name",
Args: cobra.MinimumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
client, err := newClient()
Expand All @@ -355,7 +354,10 @@ func rmEnvsCommand(user *string) *cobra.Command {
IsConfirm: true,
}
if _, err := confirm.Run(); err != nil {
return err
return clog.Fatal(
"failed to confirm prompt", clog.BlankLine,
clog.Tipf(`use "--force" to rebuild without a confirmation prompt`),
)
}
}

Expand Down