Skip to content

Commit

Permalink
Merge pull request #49 from AkihiroSuda/dev
Browse files Browse the repository at this point in the history
allow `limactl start <ALREADY_RUNNING_INSTANCE>` without raising an error
  • Loading branch information
AkihiroSuda authored Jun 15, 2021
2 parents 540282c + 3f41d48 commit 296a0aa
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
11 changes: 11 additions & 0 deletions cmd/limactl/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
14 changes: 9 additions & 5 deletions pkg/start/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}

0 comments on commit 296a0aa

Please sign in to comment.