Warn when passing git flags without repository arg

This commit is contained in:
Cristian Dominguez 2020-11-04 12:10:35 -03:00
parent c6938941d5
commit 97aa0b2f7d

View file

@ -50,8 +50,13 @@ func NewCmdFork(f *cmdutil.Factory, runF func(*ForkOptions) error) *cobra.Comman
}
cmd := &cobra.Command{
Use: "fork [<repository>] [-- <gitflags>...]",
Args: cobra.MaximumNArgs(2),
Use: "fork [<repository>] [-- <gitflags>...]",
Args: func(cmd *cobra.Command, args []string) error {
if cmd.ArgsLenAtDash() == 0 && len(args[1:]) > 0 {
return cmdutil.FlagError{Err: fmt.Errorf("repository argument required when passing 'git clone' flags")}
}
return nil
},
Short: "Create a fork of a repository",
Long: `Create a fork of a repository.