Better messaging for gh pr checkout

This commit is contained in:
Corey Johnson 2019-12-10 15:30:41 -08:00
parent 5949ca4b56
commit 5296f72189
2 changed files with 9 additions and 3 deletions

View file

@ -108,7 +108,7 @@ func issueList(cmd *cobra.Command, args []string) error {
msg := "There are no open issues" msg := "There are no open issues"
userSetFlags := false userSetFlags := false
cmd.Flags().VisitAll(func(f *pflag.Flag) { cmd.Flags().Visit(func(f *pflag.Flag) {
userSetFlags = f.Changed || userSetFlags userSetFlags = f.Changed || userSetFlags
}) })
if userSetFlags { if userSetFlags {

View file

@ -1,6 +1,7 @@
package command package command
import ( import (
"errors"
"fmt" "fmt"
"io" "io"
"os" "os"
@ -45,8 +46,13 @@ A pull request can be supplied as argument in any of the following formats:
var prCheckoutCmd = &cobra.Command{ var prCheckoutCmd = &cobra.Command{
Use: "checkout {<number> | <url> | <branch>}", Use: "checkout {<number> | <url> | <branch>}",
Short: "Check out a pull request in Git", Short: "Check out a pull request in Git",
Args: cobra.MinimumNArgs(1), Args: func(cmd *cobra.Command, args []string) error {
RunE: prCheckout, if len(args) < 1 {
return errors.New("requires a PR number as an argument")
}
return nil
},
RunE: prCheckout,
} }
var prListCmd = &cobra.Command{ var prListCmd = &cobra.Command{
Use: "list", Use: "list",