Skip to content

Commit 38d5aca

Browse files
committed
feat: launch command fix applied autosuggestions
1 parent ed69620 commit 38d5aca

File tree

2 files changed

+18
-19
lines changed

2 files changed

+18
-19
lines changed

cmd/cli/commands/launch.go

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"sort"
1010
"strings"
1111

12-
"github.com/docker/model-runner/cmd/cli/commands/completion"
1312
"github.com/docker/model-runner/cmd/cli/pkg/types"
1413
"github.com/spf13/cobra"
1514
)
@@ -63,7 +62,7 @@ var hostApps = map[string]hostApp{
6362
"opencode": {envFn: openaiEnv(openaiPathSuffix)},
6463
"codex": {envFn: openaiEnv("/v1")},
6564
"claude": {envFn: anthropicEnv},
66-
"clawdbot": {configInstructions: clawdbotConfigInstructions},
65+
"openclaw": {configInstructions: openclawConfigInstructions},
6766
}
6867

6968
// supportedApps is derived from the registries above.
@@ -89,10 +88,9 @@ func newLaunchCmd() *cobra.Command {
8988
c := &cobra.Command{
9089
Use: "launch APP [-- APP_ARGS...]",
9190
Short: "Launch an app configured to use Docker Model Runner",
92-
Long: fmt.Sprintf(`Launch an app configured to use Docker Model Runner.
93-
91+
Long: fmt.Sprintf(`Launch an app configured to use Docker Model Runner.
92+
9493
Supported apps: %s`, strings.Join(supportedApps, ", ")),
95-
Short: "Launch an app configured to use Docker Model Runner",
9694
Args: cobra.MinimumNArgs(1),
9795
ValidArgs: supportedApps,
9896
RunE: func(cmd *cobra.Command, args []string) error {
@@ -221,7 +219,7 @@ func launchHostApp(cmd *cobra.Command, bin string, baseURL string, cli hostApp,
221219
}
222220

223221
if cli.envFn == nil {
224-
return launchUnconfigurableHostApp(cmd, bin, baseURL, cli, dryRun)
222+
return launchUnconfigurableHostApp(cmd, bin, baseURL, cli, appArgs, dryRun)
225223
}
226224

227225
env := cli.envFn(baseURL)
@@ -236,7 +234,7 @@ func launchHostApp(cmd *cobra.Command, bin string, baseURL string, cli hostApp,
236234
}
237235

238236
// launchUnconfigurableHostApp handles host apps that need manual config rather than env vars.
239-
func launchUnconfigurableHostApp(cmd *cobra.Command, bin string, baseURL string, cli hostApp, dryRun bool) error {
237+
func launchUnconfigurableHostApp(cmd *cobra.Command, bin string, baseURL string, cli hostApp, appArgs []string, dryRun bool) error {
240238
enginesEP := baseURL + openaiPathSuffix
241239
cmd.Printf("Configure %s to use Docker Model Runner:\n", bin)
242240
cmd.Printf(" Base URL: %s\n", enginesEP)
@@ -250,18 +248,19 @@ func launchUnconfigurableHostApp(cmd *cobra.Command, bin string, baseURL string,
250248
}
251249
}
252250
if dryRun {
251+
cmd.Printf("Would run: %s %s\n", bin, strings.Join(appArgs, " "))
253252
return nil
254253
}
255-
return runExternal(cmd, nil, bin)
254+
return runExternal(cmd, nil, bin, appArgs...)
256255
}
257256

258-
// clawdbotConfigInstructions returns configuration commands for clawdbot.
259-
func clawdbotConfigInstructions(baseURL string) []string {
257+
// openclawConfigInstructions returns configuration commands for openclaw.
258+
func openclawConfigInstructions(baseURL string) []string {
260259
ep := baseURL + openaiPathSuffix
261260
return []string{
262-
fmt.Sprintf("clawdbot config set models.providers.docker-model-runner.baseUrl %q", ep),
263-
"clawdbot config set models.providers.docker-model-runner.api openai-completions",
264-
fmt.Sprintf("clawdbot config set models.providers.docker-model-runner.apiKey %s", dummyAPIKey),
261+
fmt.Sprintf("openclaw config set models.providers.docker-model-runner.baseUrl %q", ep),
262+
"openclaw config set models.providers.docker-model-runner.api openai-completions",
263+
fmt.Sprintf("openclaw config set models.providers.docker-model-runner.apiKey %s", dummyAPIKey),
265264
}
266265
}
267266

cmd/cli/commands/launch_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -319,16 +319,16 @@ func TestLaunchUnconfigurableHostAppDryRun(t *testing.T) {
319319
buf := new(bytes.Buffer)
320320
cmd := newTestCmd(buf)
321321

322-
cli := hostApp{configInstructions: clawdbotConfigInstructions}
323-
err := launchUnconfigurableHostApp(cmd, "clawdbot", testBaseURL, cli, true)
322+
cli := hostApp{configInstructions: openclawConfigInstructions}
323+
err := launchUnconfigurableHostApp(cmd, "openclaw", testBaseURL, cli, nil, true)
324324
require.NoError(t, err)
325325

326326
output := buf.String()
327-
require.Contains(t, output, "Configure clawdbot to use Docker Model Runner:")
327+
require.Contains(t, output, "Configure openclaw to use Docker Model Runner:")
328328
require.Contains(t, output, "Base URL: "+testBaseURL+"/engines/v1")
329329
require.Contains(t, output, "API type: openai-completions")
330330
require.Contains(t, output, "API key: "+dummyAPIKey)
331-
require.Contains(t, output, "clawdbot config set models.providers.docker-model-runner.baseUrl")
331+
require.Contains(t, output, "openclaw config set models.providers.docker-model-runner.baseUrl")
332332
}
333333

334334
func TestNewLaunchCmdFlags(t *testing.T) {
@@ -388,13 +388,13 @@ func TestNewLaunchCmdDispatchHostApp(t *testing.T) {
388388
buf := new(bytes.Buffer)
389389
cmd := newLaunchCmd()
390390
cmd.SetOut(buf)
391-
cmd.SetArgs([]string{"clawdbot", "--dry-run"})
391+
cmd.SetArgs([]string{"openclaw", "--dry-run"})
392392

393393
err = cmd.Execute()
394394
require.NoError(t, err)
395395

396396
output := buf.String()
397-
require.Contains(t, output, "Configure clawdbot to use Docker Model Runner:")
397+
require.Contains(t, output, "Configure openclaw to use Docker Model Runner:")
398398
}
399399

400400
func TestNewLaunchCmdDispatchUnsupportedApp(t *testing.T) {

0 commit comments

Comments
 (0)