Add --draft and --non-draft filters to gh pr list#4316
Conversation
caeb588 to
11466fd
Compare
| defer http.Verify(t) | ||
|
|
||
| _, err := runCommand(http, true, `-l one,two -a hubot`) | ||
| if err == nil && err.Error() != "multiple labels with --assignee are not supported" { |
There was a problem hiding this comment.
I removed this test, because it seems to be non-relevant anymore and CLI works perfectly in this case. I tested it with:
gh pr list -a vilmibm -l blocked,enhancement and it gave me this PR #3557 as a result.
It was green just because of logic error in test itself(it should have been if err == nil || err.Error() != "..." instead of if err == nil && err.Error() != "...")
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
|
@samcoe |
|
I like |
|
@SiarheiFedartsou Our commander library, Cobra, offers a boolean flag option. An example in our code base can be found here cli/pkg/cmd/issue/comment/comment.go Line 57 in d7f7a98 BoolP.
|
|
@samcoe |
|
@SiarheiFedartsou I agree, which is why I put forth that alternative suggestion, but I do think the UX is better with type ListOptions struct {
Draft bool
DraftChanged bool
}
func NewCmdList ... {
opts := &ListOptions{}
cmd := &cobra.Command{
RunE: func(cmd *cobra.Command, args []string) error {
if cmd.Flags().Changed("draft") {
opts.DraftChanged = true
}
}
cmd.Flags().BoolP(&opts.Draft, "draft", ...)
}Now the |
|
@samcoe yeah, I was thinking about something like this, but since I am not very familiar with cobra I didn't know how to accomplish it. Thanks, will give it a try! |
|
@samcoe I applied changes in UX proposed by you, please take a look one more time. |
|
@SiarheiFedartsou Thanks for the changes! I made one change which was to convert the draft boolean flag into to a string early on so that it is easier to propagate through to the search code. |
|
@SiarheiFedartsou Thanks for your work! Any chance you could edit the PR body and title to document the final expected behavior just so when people look back on the PR, they know where we landed with the flag structure and what is intended to happen in each case? |
|
I'm late to this party, but I just wanted to state for the record that I would have actually preferred separate For example, However, this new
Furthermore, it might not be clear to the user how to use this new flag. Its current documentation is: The To summarize, I see two potential problems here: that this boolean flag has 3 states (whereas other boolean flags in gh have only 2 states) and that using this filter to list non-draft PRs requires knowledge of non-obvious flag syntax. If the goal was to avoid introducing two new flags (
|
Adds
--draftand--non-draftfilters togh pr list. I didn't create new ticket for this, but it was previously mentioned in #641Implementation was done using other options as a reference: seems to work :)