Skip to content

Commit 97aa0b2

Browse files
committed
Warn when passing git flags without repository arg
1 parent c693894 commit 97aa0b2

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

pkg/cmd/repo/fork/fork.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,13 @@ func NewCmdFork(f *cmdutil.Factory, runF func(*ForkOptions) error) *cobra.Comman
5050
}
5151

5252
cmd := &cobra.Command{
53-
Use: "fork [<repository>] [-- <gitflags>...]",
54-
Args: cobra.MaximumNArgs(2),
53+
Use: "fork [<repository>] [-- <gitflags>...]",
54+
Args: func(cmd *cobra.Command, args []string) error {
55+
if cmd.ArgsLenAtDash() == 0 && len(args[1:]) > 0 {
56+
return cmdutil.FlagError{Err: fmt.Errorf("repository argument required when passing 'git clone' flags")}
57+
}
58+
return nil
59+
},
5560
Short: "Create a fork of a repository",
5661
Long: `Create a fork of a repository.
5762

0 commit comments

Comments
 (0)