diff --git a/cmd/limactl/start.go b/cmd/limactl/start.go index d1eb594fb2f..f7bf374a5a7 100644 --- a/cmd/limactl/start.go +++ b/cmd/limactl/start.go @@ -174,6 +174,17 @@ func startAction(clicontext *cli.Context) error { if err != nil { return err } + switch inst.Status { + case store.StatusRunning: + logrus.Infof("The instance %q is already running. Run `%s` to open the shell.", + inst.Name, start.LimactlShellCmd(inst.Name)) + // Not an error + return nil + case store.StatusStopped: + // NOP + default: + logrus.Warnf("expected status %q, got %q", store.StatusStopped, inst.Status) + } ctx := clicontext.Context return start.Start(ctx, inst) } diff --git a/pkg/start/start.go b/pkg/start/start.go index 651707964c6..dbfefd19a10 100644 --- a/pkg/start/start.go +++ b/pkg/start/start.go @@ -135,11 +135,7 @@ func watchHostAgentEvents(ctx context.Context, instName, haStdoutPath, haStderrP return true } - shellCmd := fmt.Sprintf("limactl shell %s", instName) - if instName == "default" { - shellCmd = "lima" - } - logrus.Infof("READY. Run `%s` to open the shell.", shellCmd) + logrus.Infof("READY. Run `%s` to open the shell.", LimactlShellCmd(instName)) err = nil return true } @@ -160,3 +156,11 @@ func watchHostAgentEvents(ctx context.Context, instName, haStdoutPath, haStderrP return nil } + +func LimactlShellCmd(instName string) string { + shellCmd := fmt.Sprintf("limactl shell %s", instName) + if instName == "default" { + shellCmd = "lima" + } + return shellCmd +}