-
Notifications
You must be signed in to change notification settings - Fork 19
Add confirmation prompt to 'coder envs edit' #305
Conversation
jawnsy
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 🔥
| gpus int | ||
| follow bool | ||
| user string | ||
| force bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice 👍
internal/cmd/envs.go
Outdated
|
|
||
| if !force && env.LatestStat.ContainerStatus == coder.EnvironmentOn { | ||
| _, err = (&promptui.Prompt{ | ||
| Label: fmt.Sprintf("Rebuild environment \"%s\"? (will destroy any work outside of /home)", env.Name), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it doesn't matter for anything, but fyi you can use %q to double quote your string (you can tell that I am extremely lazy)
| Label: fmt.Sprintf("Rebuild environment \"%s\"? (will destroy any work outside of /home)", env.Name), | |
| Label: fmt.Sprintf("Rebuild environment %q? (will destroy any work outside of /home)", env.Name), |
You might also want to mention "your home directory" instead of a specific path, because as a special case, root's home directory is /root
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree on "your home directory"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh nice - didn't know about that %q 🤯 🙌
And yeah the rename from /home to your home directory is a good call. Fixed it on the rebuild prompt too 👌
| // edit the CPU of the environment | ||
| cpu = 2.1 | ||
| res = execute(t, nil, "envs", "edit", name, fmt.Sprintf("--cpu=%f", cpu), "--follow") | ||
| res = execute(t, nil, "envs", "edit", name, fmt.Sprintf("--cpu=%f", cpu), "--follow", "--force") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
love that you added a test, TY ❤️
See CH9720 https://app.clubhouse.io/coder/story/9720/confirm-when-editing-environment-with-coder-cli