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