diff --git a/cmd/limactl/clone.go b/cmd/limactl/clone.go index 18e1c5a6fbd..bd598210d85 100644 --- a/cmd/limactl/clone.go +++ b/cmd/limactl/clone.go @@ -34,6 +34,7 @@ Not to be confused with 'limactl copy' ('limactl cp'). ValidArgsFunction: cloneBashComplete, GroupID: advancedCommand, } + cloneCommand.Flags().Bool("start", false, "Start the instance after cloning") editflags.RegisterEdit(cloneCommand, "[limactl edit] ") return cloneCommand } @@ -98,17 +99,21 @@ func cloneAction(cmd *cobra.Command, args []string) error { } } - if !tty { - // use "start" to start it - return nil - } - startNow, err := askWhetherToStart() + start, err := flags.GetBool("start") if err != nil { return err } - if !startNow { + + if tty && !flags.Changed("start") { + start, err = askWhetherToStart() + if err != nil { + return err + } + } + if !start { return nil } + err = networks.Reconcile(ctx, newInst.Name) if err != nil { return err diff --git a/cmd/limactl/edit.go b/cmd/limactl/edit.go index c503e54abd0..8640d3451c6 100644 --- a/cmd/limactl/edit.go +++ b/cmd/limactl/edit.go @@ -36,6 +36,7 @@ func newEditCommand() *cobra.Command { ValidArgsFunction: editBashComplete, GroupID: basicCommand, } + editCommand.Flags().Bool("start", false, "Start the instance after editing") editflags.RegisterEdit(editCommand, "") return editCommand } @@ -140,21 +141,26 @@ func editAction(cmd *cobra.Command, args []string) error { logrus.Infof("Instance %q configuration edited", inst.Name) } - if !tty { - // use "start" to start it - return nil - } if inst == nil { // edited a limayaml file directly return nil } - startNow, err := askWhetherToStart() + + start, err := flags.GetBool("start") if err != nil { return err } - if !startNow { + + if tty && !flags.Changed("start") { + start, err = askWhetherToStart() + if err != nil { + return err + } + } + if !start { return nil } + err = networks.Reconcile(ctx, inst.Name) if err != nil { return err diff --git a/cmd/limactl/main.go b/cmd/limactl/main.go index 39b93421a72..92c2b1b8ca9 100644 --- a/cmd/limactl/main.go +++ b/cmd/limactl/main.go @@ -143,6 +143,11 @@ func newApp() *cobra.Command { } if cmd.Flags().Changed("yes") { + switch cmd.Name() { + case "clone", "edit": + logrus.Warn("--yes flag is deprecated (--tty=false is still supported and works in the same way. Also consider using --start)") + } + // Sets the value of the yesValue flag by using the yes flag. yesValue, _ := cmd.Flags().GetBool("yes") if yesValue {