Add better message to empty gh issue list

This commit is contained in:
Corey Johnson 2019-12-06 14:10:01 -08:00
parent 9aa3f35f8a
commit 00b38bb11c
2 changed files with 15 additions and 6 deletions

View file

@ -13,6 +13,7 @@ import (
"github.com/github/gh-cli/utils"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
)
func init() {
@ -98,14 +99,22 @@ func issueList(cmd *cobra.Command, args []string) error {
return err
}
out := cmd.OutOrStdout()
colorOut := colorableOut(cmd)
if len(issues) == 0 {
printMessage(colorOut, "There are no open issues")
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
msg := "There are no open issues"
userSetFlags := false
cmd.Flags().VisitAll(func(f *pflag.Flag) {
userSetFlags = f.Changed || userSetFlags
})
if userSetFlags {
msg = "No issues match your search"
}
printMessage(colorErr, msg)
return nil
}
out := cmd.OutOrStdout()
table := utils.NewTablePrinter(out)
for _, issue := range issues {
issueNum := strconv.Itoa(issue.Number)

View file

@ -182,7 +182,7 @@ func prList(cmd *cobra.Command, args []string) error {
}
if len(prs) == 0 {
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
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
msg := "There are no open pull requests"
userSetFlags := false
@ -190,7 +190,7 @@ func prList(cmd *cobra.Command, args []string) error {
userSetFlags = f.Changed || userSetFlags
})
if userSetFlags {
msg = "No pull requests matched your search"
msg = "No pull requests match your search"
}
printMessage(colorErr, msg)
return nil