Require non-empty selector when --repo override is used

Signed-off-by: Babak K. Shandiz <babak.k.shandiz@gmail.com>
This commit is contained in:
Babak K. Shandiz 2024-04-14 12:25:01 +01:00
parent 6856d0fcef
commit f85d0ebaed
No known key found for this signature in database
GPG key ID: 44950AED81AD710F

View file

@ -48,11 +48,16 @@ func NewCmdUpdate(f *cmdutil.Factory, runF func(*UpdateOptions) error) *cobra.Co
Example: heredoc.Doc(`
$ gh pr update 23
$ gh pr update 23 --rebase
$ gh pr update 23 --repo owner/repo
`),
Args: cobra.MaximumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
opts.Finder = shared.NewFinder(f)
if repoOverride, _ := cmd.Flags().GetString("repo"); repoOverride != "" && len(args) == 0 {
return cmdutil.FlagErrorf("argument required when using the --repo flag")
}
if len(args) > 0 {
opts.SelectorArg = args[0]
}