Skip to content
This repository was archived by the owner on Oct 6, 2025. It is now read-only.

Commit 935b699

Browse files
committed
configure: validate exactly one model argument before -- separator
Signed-off-by: Dorin Geman <[email protected]>
1 parent c3a000b commit 935b699

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

commands/configure.go

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,23 @@ func newConfigureCmd() *cobra.Command {
1414
Use: "configure [--context-size=<n>] MODEL [-- <runtime-flags...>]",
1515
Short: "Configure runtime options for a model",
1616
Args: func(cmd *cobra.Command, args []string) error {
17-
if len(args) < 1 {
18-
return fmt.Errorf(
19-
"Model specification is required.\n\n" +
20-
"See 'docker model configure --help' for more information",
21-
)
17+
argsBeforeDash := cmd.ArgsLenAtDash()
18+
if argsBeforeDash == -1 {
19+
// No "--" used, so we need exactly 1 total argument.
20+
if len(args) != 1 {
21+
return fmt.Errorf(
22+
"Exactly one model must be specified, got %d: %v\n\n"+
23+
"See 'docker model configure --help' for more information",
24+
len(args), args)
25+
}
26+
} else {
27+
// Has "--", so we need exactly 1 argument before it.
28+
if argsBeforeDash != 1 {
29+
return fmt.Errorf(
30+
"Exactly one model must be specified before --, got %d\n\n"+
31+
"See 'docker model configure --help' for more information",
32+
argsBeforeDash)
33+
}
2234
}
2335
opts.Model = args[0]
2436
opts.RuntimeFlags = args[1:]

0 commit comments

Comments
 (0)