From 5296f72189fc6ff5215e2a7a4e0f962137973c7d Mon Sep 17 00:00:00 2001 From: Corey Johnson Date: Tue, 10 Dec 2019 15:30:41 -0800 Subject: [PATCH] Better messaging for `gh pr checkout` --- command/issue.go | 2 +- command/pr.go | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/command/issue.go b/command/issue.go index 958bcb9bd..cc93c6e81 100644 --- a/command/issue.go +++ b/command/issue.go @@ -108,7 +108,7 @@ func issueList(cmd *cobra.Command, args []string) error { msg := "There are no open issues" userSetFlags := false - cmd.Flags().VisitAll(func(f *pflag.Flag) { + cmd.Flags().Visit(func(f *pflag.Flag) { userSetFlags = f.Changed || userSetFlags }) if userSetFlags { diff --git a/command/pr.go b/command/pr.go index e72b73024..790e27fef 100644 --- a/command/pr.go +++ b/command/pr.go @@ -1,6 +1,7 @@ package command import ( + "errors" "fmt" "io" "os" @@ -45,8 +46,13 @@ A pull request can be supplied as argument in any of the following formats: var prCheckoutCmd = &cobra.Command{ Use: "checkout { | | }", Short: "Check out a pull request in Git", - Args: cobra.MinimumNArgs(1), - RunE: prCheckout, + Args: func(cmd *cobra.Command, args []string) error { + if len(args) < 1 { + return errors.New("requires a PR number as an argument") + } + return nil + }, + RunE: prCheckout, } var prListCmd = &cobra.Command{ Use: "list",