Skip to content

Commit 4d359c7

Browse files
[Crane: crane-migration-python-to-go-full-apm-cli-rewrite] Iteration 148: fix mcp install probe parity (revert iter148/8f799e3b name-collection regression)
Changes: Python Click ignore_unknown_options=True sends --X to ctx.args, not NAME. Remove the dead startsWith(name, "-") block added by 8f799e3 which emitted a wrong stdout [!] line and wrong stderr install-context error. Now 'apm mcp install --definitely-not-an-apm-option' -> name=="" -> 4-line missing-arg error (Usage/Try/blank/Error) matching Python rc=2. Run: https://github.com/githubnext/apm/actions/runs/28279263309 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent f0bb2b9 commit 4d359c7

1 file changed

Lines changed: 3 additions & 11 deletions

File tree

cmd/apm/cmd_mcp.go

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ func runMCPInstall(args []string) int {
9494
case "--limit":
9595
i++ // skip value
9696
default:
97-
// Python Click ignore_unknown_options=True accepts any first arg as NAME,
98-
// even if it starts with '-'.
99-
if !startsWith(a, "--limit=") && name == "" {
97+
// Python Click ignore_unknown_options=True puts --X args into ctx.args,
98+
// not into the NAME positional. Only non-dash args are positional.
99+
if !startsWith(a, "--limit=") && !startsWith(a, "-") && name == "" {
100100
name = a
101101
}
102102
}
@@ -108,14 +108,6 @@ func runMCPInstall(args []string) int {
108108
fmt.Fprintln(os.Stderr, "Error: Missing argument 'NAME'.")
109109
return 2
110110
}
111-
if startsWith(name, "-") {
112-
fmt.Print("[!] Install interrupted after 0.0s.\n")
113-
fmt.Fprintln(os.Stderr, "Usage: apm install [OPTIONS] [PACKAGES]...")
114-
fmt.Fprintln(os.Stderr, "Try 'apm install --help' for help.")
115-
fmt.Fprintln(os.Stderr, "")
116-
fmt.Fprintln(os.Stderr, "Error: MCP name cannot start with '-'; did you forget a value for --mcp?")
117-
return 2
118-
}
119111

120112
cwd, _ := os.Getwd()
121113
ymlPath, err := findApmYML(cwd)

0 commit comments

Comments
 (0)