Skip to content
This repository was archived by the owner on Oct 6, 2025. It is now read-only.
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions commands/compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package commands

import (
"encoding/json"
"errors"
"fmt"
"os"

"github.com/docker/model-cli/desktop"
"github.com/spf13/cobra"
Expand All @@ -22,18 +22,26 @@ func newComposeCmd(desktopClient *desktop.Client) *cobra.Command {
return c
}

type Options struct {
Model string `json:"model,omitempty"`
}

func newUpCommand(desktopClient *desktop.Client) *cobra.Command {
var model string
c := &cobra.Command{
Use: "up",
RunE: func(cmd *cobra.Command, args []string) error {
if model == "" {
err := errors.New("options.model is required")
sendError(err.Error())
var opts Options
err := json.NewDecoder(os.Stdin).Decode(opts)
if err != nil {
sendError("failed to parse options")
return err
}
if opts.Model == "" {
sendError("options.model is required")
return err
}

_, _, err := desktopClient.Pull(model, func(s string) {
_, _, err = desktopClient.Pull(opts.Model, func(s string) {
sendInfo(s)
})
if err != nil {
Expand All @@ -43,25 +51,22 @@ func newUpCommand(desktopClient *desktop.Client) *cobra.Command {

// FIXME get actual URL from Docker Desktop
setenv("URL", "http://model-runner.docker.internal/engines/v1/")
setenv("MODEL", model)
setenv("MODEL", opts.Model)

return nil
},
}
c.Flags().StringVar(&model, "model", "", "model to use")
return c
}

func newDownCommand() *cobra.Command {
var model string
c := &cobra.Command{
Use: "down",
RunE: func(cmd *cobra.Command, args []string) error {
// No required cleanup on down
return nil
},
}
c.Flags().StringVar(&model, "model", "", "model to use")
return c
}

Expand Down