Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Aug 30, 2024. It is now read-only.
/coder-v1-cliPublic archive

feat: Prompt user to rebuild workspace on coder sh#223

Merged
Emyrk merged 1 commit intomasterfromstevenmasley/ch6142_sh_start_wksp
Jan 22, 2021

Conversation

Emyrk
Copy link
Member

Quality of Life Feature

When a user doescoder sh <env>, the cli first checks if that environment isOFF or if it requires a rebuild before using. It will then prompt the user if they want to rebuild the workspace.

To test

Off

coder env stop <workspace>coder sh <workspace>

Rebuild Message

If the environment has a required rebuild message, the output looks like this:
Screenshot from 2021-01-21 16-22-16

Questions:

Currently--force does not work for this feature, and there is no--no-rebuild flag. The current command has flag parsing disabled. Are these kinds of flags required? I imagine a user prompt would make scriptingcoder sh rather annoying.

cmoog reacted with rocket emoji
@EmyrkEmyrk requested a review fromcmoogJanuary 21, 2021 23:00
Comment on lines 135 to 139
confirm := promptui.Prompt{
Label: rebuildReason + " Do you wish to rebuild it now? (this will take a moment)",
IsConfirm: true,
}
if _, err := confirm.Run(); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

we should only prompt the user if they are in an interactive terminal

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Is this what you had in mind to check for that?
https://github.com/cdr/coder-cli/blob/423279755e6607dc1236066d47fd5333d25268b5/internal/cmd/shell.go#L107-L109

So these willnot prompt:

$GOPATH/bin/coder sh tiny | echo`/home/coder/go/bin/coder sh tiny`

Is there a specific way of executing you had in mind? I took this code from therunCommand, an alternative is I could usehttps://rosettacode.org/wiki/Check_output_device_is_a_terminal#Go. I think they do the same thing, so I kept it consistent with the other way we did it.

Copy link
Contributor

@cmoogcmoogJan 22, 2021
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Yeah that's what I had in mind. That said, point taken... this is certainly leaky behavior. Since this is more of a nicety, and we can assume 90% of cases will becoder sh [env] without pipes or args... I think we should do the cautious thing and only show the prompt when we know for certain the output is interactive.

Regardingcoder sh tiny | echo, erroring out as we do now with the helpful error message seems sufficient.

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I left a comment that--force or--no-prompt would be a clear way for someone to determine behavior, but adding flags to this command is non-trivial because the flag parsing is disabled

cmoog reacted with thumbs up emoji
Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I am assuming running this viacron and other ways won't trigger the prompt too. So I can see how this is helpful, but I don't think it's obvious if I was just writing some bash scripts. Bash scripts will still trigger the prompt if you just run them./script.sh.

cmoog reacted with thumbs up emoji
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Yes, agreed. Doesn't appear to be an easy win here.

@EmyrkEmyrk marked this pull request as ready for reviewJanuary 22, 2021 15:17
@Emyrk
Copy link
MemberAuthor

@cmoog addressed all comments, the last sticky point is if the current interactive shell behavior is sufficient

cmoog reacted with thumbs up emoji

Comment on lines 135 to 139
confirm := promptui.Prompt{
Label: rebuildReason + " Do you wish to rebuild it now? (this will take a moment)",
IsConfirm: true,
}
if _, err := confirm.Run(); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Yes, agreed. Doesn't appear to be an easy win here.

Copy link
Contributor

@cmoogcmoog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Looks good. Nice work.

I think the interactive behavior, as you have it, is the best we're going to get for now.

If the workspace is OFF or a rebuild is required, promptthe user to rebuild right away. This prompt only occursin an interactive shell
@EmyrkEmyrkforce-pushed thestevenmasley/ch6142_sh_start_wksp branch from6752124 to7a4f2dbCompareJanuary 22, 2021 17:57
@EmyrkEmyrk merged commit288197a intomasterJan 22, 2021
@EmyrkEmyrk deleted the stevenmasley/ch6142_sh_start_wksp branchJanuary 22, 2021 18:36
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@cmoogcmoogcmoog approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@Emyrk@cmoog

[8]ページ先頭

©2009-2025 Movatter.jp