Skip to content

Commit 296a0aa

Browse files
authored
Merge pull request #49 from AkihiroSuda/dev
allow `limactl start <ALREADY_RUNNING_INSTANCE>` without raising an error
2 parents 540282c + 3f41d48 commit 296a0aa

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

cmd/limactl/start.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,17 @@ func startAction(clicontext *cli.Context) error {
174174
if err != nil {
175175
return err
176176
}
177+
switch inst.Status {
178+
case store.StatusRunning:
179+
logrus.Infof("The instance %q is already running. Run `%s` to open the shell.",
180+
inst.Name, start.LimactlShellCmd(inst.Name))
181+
// Not an error
182+
return nil
183+
case store.StatusStopped:
184+
// NOP
185+
default:
186+
logrus.Warnf("expected status %q, got %q", store.StatusStopped, inst.Status)
187+
}
177188
ctx := clicontext.Context
178189
return start.Start(ctx, inst)
179190
}

pkg/start/start.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,7 @@ func watchHostAgentEvents(ctx context.Context, instName, haStdoutPath, haStderrP
135135
return true
136136
}
137137

138-
shellCmd := fmt.Sprintf("limactl shell %s", instName)
139-
if instName == "default" {
140-
shellCmd = "lima"
141-
}
142-
logrus.Infof("READY. Run `%s` to open the shell.", shellCmd)
138+
logrus.Infof("READY. Run `%s` to open the shell.", LimactlShellCmd(instName))
143139
err = nil
144140
return true
145141
}
@@ -160,3 +156,11 @@ func watchHostAgentEvents(ctx context.Context, instName, haStdoutPath, haStderrP
160156

161157
return nil
162158
}
159+
160+
func LimactlShellCmd(instName string) string {
161+
shellCmd := fmt.Sprintf("limactl shell %s", instName)
162+
if instName == "default" {
163+
shellCmd = "lima"
164+
}
165+
return shellCmd
166+
}

0 commit comments

Comments
 (0)