Skip to content

Commit 286334f

Browse files
[Crane: crane-migration-python-to-go-full-apm-cli-rewrite] Iteration 147: fix mcp install probe parity (revert iter146 name-collection regression)
Root cause of PYTHON_CLI_CONTRACT_STATUS=1: iter146 changed runMCPInstall to accept dash-prefixed args as NAME and emit an install-context 4-line error. This contradicts the lesson from iter143: Python Click ignore_unknown_options=True routes --X args to ctx.args (not to the NAME positional), so Python outputs the 2-line 'Error: Missing argument NAME.' format. Fix: restore the dash-prefix filter (iter143 behavior) and keep the 'Try ...' line added in iter146. The if startsWith(name, '-') block is removed since it is unreachable after the filter. errcli.go is unchanged -- iter146's fix there (removing wrong-quote transform) was correct and remains. Run: https://github.com/githubnext/apm/actions/runs/28274189929 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent bc59c5d commit 286334f

1 file changed

Lines changed: 3 additions & 13 deletions

File tree

cmd/apm/cmd_mcp.go

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,9 @@ func runMCPInstall(args []string) int {
8383
case "--limit":
8484
i++ // skip value
8585
default:
86-
// Mirror Python Click ignore_unknown_options=True: any non-flag arg
87-
// (including dash-prefixed) is accepted as NAME positional, just as
88-
// Click assigns it to ctx.args and then to the NAME argument.
89-
if !startsWith(a, "--limit=") && name == "" {
86+
// Python Click ignore_unknown_options=True puts --X args into ctx.args,
87+
// not into the NAME positional. Only non-dash args are positional.
88+
if !startsWith(a, "--limit=") && !startsWith(a, "-") && name == "" {
9089
name = a
9190
}
9291
}
@@ -96,15 +95,6 @@ func runMCPInstall(args []string) int {
9695
fmt.Fprintln(os.Stderr, "Try 'apm mcp install --help' for help.")
9796
return 2
9897
}
99-
// Python forwards: cli.main(["install", "--mcp", name, ...], standalone_mode=False)
100-
// When name starts with '-', apm install rejects it as an unknown option.
101-
// Mirror that: emit the install-context unknown-option error so errcli.go
102-
// produces the same 4-line format Python Click generates.
103-
if startsWith(name, "-") {
104-
fmt.Fprintf(os.Stderr, "Error: No such option: %s\n", name)
105-
fmt.Fprintln(os.Stderr, "Try 'apm install --help' for help.")
106-
return 2
107-
}
10898

10999
cwd, _ := os.Getwd()
110100
ymlPath, err := findApmYML(cwd)

0 commit comments

Comments
 (0)