Skip to content

Commit 8294bed

Browse files
committed
feat: Add start prompt to limactl create
Signed-off-by: opjt <[email protected]>
1 parent 88173f0 commit 8294bed

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

cmd/limactl/start.go

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -549,11 +549,34 @@ func createAction(cmd *cobra.Command, args []string) error {
549549
if len(inst.Errors) > 0 {
550550
return fmt.Errorf("errors inspecting instance: %+v", inst.Errors)
551551
}
552-
if _, err = instance.Prepare(cmd.Context(), inst, ""); err != nil {
552+
ctx := cmd.Context()
553+
if _, err = instance.Prepare(ctx, inst, ""); err != nil {
554+
return err
555+
}
556+
tty, err := cmd.Flags().GetBool("tty")
557+
if err != nil {
558+
return err
559+
}
560+
561+
startNow := false
562+
if tty {
563+
startNow, err = askWhetherToStart()
564+
if err != nil {
565+
return err
566+
}
567+
}
568+
569+
if !startNow {
570+
logrus.Infof("Run `limactl start %s` to start the instance.", inst.Name)
571+
return nil
572+
}
573+
574+
if err := instance.Start(ctx, inst, false, false); err != nil {
553575
return err
554576
}
555-
logrus.Infof("Run `limactl start %s` to start the instance.", inst.Name)
577+
556578
return nil
579+
557580
}
558581

559582
func startAction(cmd *cobra.Command, args []string) error {

0 commit comments

Comments
 (0)