Skip to content

Commit 00b38bb

Browse files
committed
Add better message to empty gh issue list
1 parent 9aa3f35 commit 00b38bb

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

command/issue.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"github.com/github/gh-cli/utils"
1414
"github.com/pkg/errors"
1515
"github.com/spf13/cobra"
16+
"github.com/spf13/pflag"
1617
)
1718

1819
func init() {
@@ -98,14 +99,22 @@ func issueList(cmd *cobra.Command, args []string) error {
9899
return err
99100
}
100101

101-
out := cmd.OutOrStdout()
102-
colorOut := colorableOut(cmd)
103-
104102
if len(issues) == 0 {
105-
printMessage(colorOut, "There are no open issues")
103+
colorErr := colorableErr(cmd) // Send to stderr because otherwise when piping this command it would seem like the "no open issues" message is acually an issue
104+
msg := "There are no open issues"
105+
106+
userSetFlags := false
107+
cmd.Flags().VisitAll(func(f *pflag.Flag) {
108+
userSetFlags = f.Changed || userSetFlags
109+
})
110+
if userSetFlags {
111+
msg = "No issues match your search"
112+
}
113+
printMessage(colorErr, msg)
106114
return nil
107115
}
108116

117+
out := cmd.OutOrStdout()
109118
table := utils.NewTablePrinter(out)
110119
for _, issue := range issues {
111120
issueNum := strconv.Itoa(issue.Number)

command/pr.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,15 +182,15 @@ func prList(cmd *cobra.Command, args []string) error {
182182
}
183183

184184
if len(prs) == 0 {
185-
colorErr := colorableErr(cmd) // If the user is piping this command we don't want them to process this message as if it were a PR entry
185+
colorErr := colorableErr(cmd) // Send to stderr because otherwise when piping this command it would seem like the "no open prs" message is acually a pr
186186
msg := "There are no open pull requests"
187187

188188
userSetFlags := false
189189
cmd.Flags().VisitAll(func(f *pflag.Flag) {
190190
userSetFlags = f.Changed || userSetFlags
191191
})
192192
if userSetFlags {
193-
msg = "No pull requests matched your search"
193+
msg = "No pull requests match your search"
194194
}
195195
printMessage(colorErr, msg)
196196
return nil

0 commit comments

Comments
 (0)