mirror of
https://github.com/morluto/rea.git
synced 2026-11-22 14:35:45 +00:00
fix(setup): list supported clients instead of a suggestion for an empty client name
An empty or whitespace-only --client or --skill-client value normalizes to an empty key, which is a prefix of every id, so suggestion ranking named an arbitrary client. Skip the suggestion for an empty key and report the supported list.
This commit is contained in:
1 parent
fe1f851057
commit
244cb64677
2 files changed
+16
-1
No files matched your search
@@ -39,7 +39,9 @@ const unknownClientMessage = (
|
||||
candidates: readonly string[],
|
||||
): string | undefined => {
|
||||
if (typeof input !== "string") return undefined;
|
||||
const suggestion = suggestCommand(normalizedClientName(input), candidates);
|
||||
const key = normalizedClientName(input);
|
||||
// An empty key is a prefix of every id, so ranking would name an arbitrary one.
|
||||
const suggestion = key === "" ? undefined : suggestCommand(key, candidates);
|
||||
return suggestion === undefined
|
||||
? `Unknown client '${input}'. Supported clients: ${candidates.join(", ")}.`
|
||||
: `Unknown client '${input}'. Did you mean '${suggestion}'?`;
|
||||
|
||||
@@ -74,4 +74,17 @@ describe("client option schemas", () => {
|
||||
/^Unknown client 'zzzz'\. Supported clients: shared, claude_code, /u,
|
||||
);
|
||||
});
|
||||
|
||||
it.each(["", " ", "\t"])(
|
||||
"lists the supported clients instead of a suggestion for %j",
|
||||
(input) => {
|
||||
const [issue] = failure({ client: [input] });
|
||||
expect(issue?.path).toEqual(["client", 0]);
|
||||
expect(issue?.message).not.toContain("Did you mean");
|
||||
expect(issue?.message).toMatch(/Supported clients: claude_code, /u);
|
||||
const [skill] = failure({ skillClient: [input] });
|
||||
expect(skill?.message).not.toContain("Did you mean");
|
||||
expect(skill?.message).toMatch(/Supported clients: shared, /u);
|
||||
},
|
||||
);
|
||||
});
|
||||
Reference in new issue
Block a user