1package cmd
 2
 3import "github.com/spf13/cobra"
 4
 5func renameCommand() *cobra.Command {
 6	cmd := &cobra.Command{
 7		Use:               "rename REPOSITORY NEW_NAME",
 8		Aliases:           []string{"mv", "move"},
 9		Short:             "Rename an existing repository",
10		Args:              cobra.ExactArgs(2),
11		PersistentPreRunE: checkIfCollab,
12		RunE: func(cmd *cobra.Command, args []string) error {
13			cfg, _ := fromContext(cmd)
14			oldName := args[0]
15			newName := args[1]
16			if err := cfg.Backend.RenameRepository(oldName, newName); err != nil {
17				return err
18			}
19			return nil
20		},
21	}
22
23	return cmd
24}