11package clone
22
33import (
4+ "fmt"
45 "net/http"
56 "strings"
67
@@ -13,6 +14,7 @@ import (
1314 "github.com/cli/cli/pkg/cmdutil"
1415 "github.com/cli/cli/pkg/iostreams"
1516 "github.com/spf13/cobra"
17+ "github.com/spf13/pflag"
1618)
1719
1820type CloneOptions struct {
@@ -33,16 +35,18 @@ func NewCmdClone(f *cmdutil.Factory, runF func(*CloneOptions) error) *cobra.Comm
3335 }
3436
3537 cmd := & cobra.Command {
36- Use : "clone <repository> [<directory>]" ,
38+ DisableFlagsInUseLine : true ,
39+
40+ Use : "clone <repository> [<directory>] [-- <gitflags>...]" ,
3741 Args : cobra .MinimumNArgs (1 ),
3842 Short : "Clone a repository locally" ,
39- Long : heredoc .Doc (
40- ` Clone a GitHub repository locally.
43+ Long : heredoc .Doc (`
44+ Clone a GitHub repository locally.
4145
4246 If the "OWNER/" portion of the "OWNER/REPO" repository argument is omitted, it
4347 defaults to the name of the authenticating user.
4448
45- To pass 'git clone' flags, separate them with '--'.
49+ Pass additional 'git clone' flags by listing them after '--'.
4650 ` ),
4751 RunE : func (cmd * cobra.Command , args []string ) error {
4852 opts .Repository = args [0 ]
@@ -56,6 +60,13 @@ func NewCmdClone(f *cmdutil.Factory, runF func(*CloneOptions) error) *cobra.Comm
5660 },
5761 }
5862
63+ cmd .SetFlagErrorFunc (func (cmd * cobra.Command , err error ) error {
64+ if err == pflag .ErrHelp {
65+ return err
66+ }
67+ return & cmdutil.FlagError {Err : fmt .Errorf ("%w\n Separate git clone flags with '--'." , err )}
68+ })
69+
5970 return cmd
6071}
6172
0 commit comments