diff --git a/command/issue.go b/command/issue.go index 0dd35ca4f..10ecf8a08 100644 --- a/command/issue.go +++ b/command/issue.go @@ -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) diff --git a/command/pr.go b/command/pr.go index 16695798f..d3bd8dece 100644 --- a/command/pr.go +++ b/command/pr.go @@ -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