@@ -30,15 +30,30 @@ func newCloneCommand() *cobra.Command {
3030Not to be confused with 'limactl copy' ('limactl cp').
3131` ,
3232 Args : WrapArgsError (cobra .ExactArgs (2 )),
33- RunE : cloneAction ,
33+ RunE : cloneOrRenameAction ,
3434 ValidArgsFunction : cloneBashComplete ,
3535 GroupID : advancedCommand ,
3636 }
3737 editflags .RegisterEdit (cloneCommand , "[limactl edit] " )
3838 return cloneCommand
3939}
4040
41- func cloneAction (cmd * cobra.Command , args []string ) error {
41+ func newRenameCommand () * cobra.Command {
42+ renameCommand := & cobra.Command {
43+ Use : "rename OLDINST NEWINST" ,
44+ // No "mv" alias, to avoid confusion with a theoretical equivalent of `limactl cp` but s/cp/mv/.
45+ Short : "Rename an instance of Lima" ,
46+ Args : WrapArgsError (cobra .ExactArgs (2 )),
47+ RunE : cloneOrRenameAction ,
48+ ValidArgsFunction : cloneBashComplete ,
49+ GroupID : advancedCommand ,
50+ }
51+ editflags .RegisterEdit (renameCommand , "[limactl edit] " )
52+ return renameCommand
53+ }
54+
55+ func cloneOrRenameAction (cmd * cobra.Command , args []string ) error {
56+ rename := cmd .Name () == "rename"
4257 ctx := cmd .Context ()
4358 flags := cmd .Flags ()
4459 tty , err := flags .GetBool ("tty" )
@@ -55,7 +70,7 @@ func cloneAction(cmd *cobra.Command, args []string) error {
5570 return err
5671 }
5772
58- newInst , err := instance .Clone (ctx , oldInst , newInstName )
73+ newInst , err := instance .CloneOrRename (ctx , oldInst , newInstName , rename )
5974 if err != nil {
6075 return err
6176 }
0 commit comments