1package cmd
 2
 3import (
 4	"github.com/charmbracelet/soft-serve/server/backend"
 5	"github.com/spf13/cobra"
 6)
 7
 8func renameCommand() *cobra.Command {
 9	cmd := &cobra.Command{
10		Use:               "rename REPOSITORY NEW_NAME",
11		Aliases:           []string{"mv", "move"},
12		Short:             "Rename an existing repository",
13		Args:              cobra.ExactArgs(2),
14		PersistentPreRunE: checkIfCollab,
15		RunE: func(cmd *cobra.Command, args []string) error {
16			ctx := cmd.Context()
17			be := backend.FromContext(ctx)
18			oldName := args[0]
19			newName := args[1]
20
21			return be.RenameRepository(ctx, oldName, newName)
22		},
23	}
24
25	return cmd
26}