Skip to content

Commit ca8d032

Browse files
committed
Add custom error for gh repo clone
1 parent bb6851c commit ca8d032

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

pkg/cmd/repo/clone/clone.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package clone
22

33
import (
4+
"fmt"
45
"net/http"
56
"strings"
67

@@ -12,6 +13,7 @@ import (
1213
"github.com/cli/cli/pkg/cmdutil"
1314
"github.com/cli/cli/pkg/iostreams"
1415
"github.com/spf13/cobra"
16+
"github.com/spf13/pflag"
1517
)
1618

1719
type CloneOptions struct {
@@ -55,6 +57,13 @@ func NewCmdClone(f *cmdutil.Factory, runF func(*CloneOptions) error) *cobra.Comm
5557
},
5658
}
5759

60+
cmd.SetFlagErrorFunc(func(cmd *cobra.Command, err error) error {
61+
if err == pflag.ErrHelp {
62+
return err
63+
}
64+
return &cmdutil.FlagError{Err: fmt.Errorf("%v\nSeparate git clone flags with `--`.", err)}
65+
})
66+
5867
return cmd
5968
}
6069

0 commit comments

Comments
 (0)