-
Couldn't load subscription status.
- Fork 7.3k
Create issue comments #2535
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create issue comments #2535
Conversation
b589f1a to
3d3815e
Compare
pkg/cmd/issue/comment/comment.go
Outdated
| IO: f.IOStreams, | ||
| HttpClient: f.HttpClient, | ||
| Config: f.Config, | ||
| Edit: func(editorCommand string) (string, error) { |
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.
This pattern is necessary for testing purposes and copied from the gist commands.
1a2402d to
df399e3
Compare
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.
This is looking great! Some suggestions on how we could simplify the interactivity around the command and its implementation
pkg/cmd/issue/comment/comment.go
Outdated
| Message: "Where do you want to draft your comment?", | ||
| Options: []string{"In line", "Editor", "Web"}, |
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'm not sure if this survey prompt is useful. I'm imagining that, if our users were to write a comment interactively, they would appreciate if we launched a text editor immediately.
Would we consider --editor being implied (and removing it as an explicit flag) if --body and --web were not supplied? And then launching an editor directly without prompting, since the user already gave us an indication that they want to write a comment?
That would mean that we would only interface with the Survey library to show the Submit? step once the editor finishes.
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.
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 think jumping straight into the editor from the prompt would be jarring, especially because it's very unlike the rest of gh to do so. I'd prefer to keep the design of this as is, but if you both feel strongly I'm open to discussing it! Curious if @vilmibm has thoughts.
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'm unsure about this and for that reason do want to ship it like this; i want to see how it feels and if we get feedback on it.
i think we're still establishing best practices around interactive modes and some inconsistency / extra verbosity might help us narrow down those practices.
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 think jumping straight into the editor from the prompt would be jarring, especially because it's very unlike the rest of gh to do so.
Agreed that it might be jarring. But for a purpose like editing, where there is only one field to collect (as opposed to opening an issue or PR), I think that it could be something that we could get away with. However, if we were to also provide the Web option, then absolutely, the first prompt is in order.
My objection was mostly for providing the In line vs. Editor option, as I don't understand why users would choose the In line option (where neither readline nor terminal escape sequences are supported), over their full-featured editor?
The second thing that I believe can reduce friction is that we skip the additional [e] to launch editor prompt which follows the user's choice of Editor, and jump straight into editing instead:
? Where do you want to draft your comment? Editor
? Body [(e) to launch vim] <--- does anyone benefit from this?
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 played around with this a bit and decided to keep the input survey but removed the In line option. The main reason was because survey does not use readline and does not handle terminal escape sequences well, this made the overall editing experience poor. If users want to supply the body message in line they will need to use the --body flag.
I agree that the second prompt to open the editor is unnecessary and will see if I can remove it.
4b56877 to
04247bf
Compare
|
Experience |
04247bf to
de73b16
Compare
|
Sam (2021/01/05 10:46 -0800):
@samcoe commented on this pull request.
> + if opts.Interactive {
+ cs := opts.IO.ColorScheme()
+ fmt.Fprint(opts.IO.Out, cs.GreenBold("?"))
+ fmt.Fprint(opts.IO.Out, cs.Bold(" Body "))
+ fmt.Fprint(opts.IO.Out, cs.Cyan("<Received>\n"))
+ }
I ended up removing the extra survey that prompts the user to enter
"e" to open their editor but that also removed the confirmation
output. I liked the little confirmation that `gh` had received the
body from the editor so I recreated it here, keeping the same survey
style.
What about making this ocnfirmation optional so that those who like it
can enable it and the others can disable it?
|
b7dd4b1 to
155507d
Compare
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.
This works and looks great! Good job π
api/queries_comments.go
Outdated
| return &Comments{Nodes: comments, TotalCount: len(comments)}, nil | ||
| } | ||
|
|
||
| func CommentCreate(client *Client, repoHost string, params map[string]string) (string, error) { |
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.
If this method is only to be used in pkg/cmd/issue and pkg/cmd/pr packages, consider placing it in pkg/cmd/issue/shared/http.go instead. I feel like we should shrink down the API package to only have generic API functionality, and specific queries are implemented in individual packages that need them.
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'd like to think about this more so I am going to leave it in place for this PR and then address it when working on commenting for PRs.
| EditSurvey: editSurvey(f.Config, f.IOStreams), | ||
| InputTypeSurvey: inputTypeSurvey, | ||
| ConfirmSubmitSurvey: confirmSubmitSurvey, | ||
| OpenInBrowser: utils.OpenInBrowser, |
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.
This is cool! π
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.
Fantastic. Thank you for the updates! π
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.
GitHub CLI comment test
|
Wait! I cannot comment normally? I have to review it? |
|
@itsme-alan Please test CLI functionality in a separate repo, and if you find a bug in merged functionality, please open an issue. Note that this PR only advertises functionality to comment on Issues; to comment on Pull Requests (this is separate from leaving a review comment, which is already possible) some additional changes might be required. π |
This PR allows for commenting on issues. It is branched off of @Yuuki77's work in #2008. Thanks @Yuuki77 for getting this work started π . I left major design decisions/comments inline with the code.
One feature I would like to add in the future is showing the most recent comments in editor mode, to give the user context for their comment. I think having #2462 merged in would make that feature significantly easier to implement which is why I am going to hold off for now. If that gets merged in before this one, then I will take a pass at implementing it.
cc #517