242
return undefined;
243
}
245
>
const namedOptions = descriptor.options.filter(o => o.arg !== undefined);
246
>
const baseOption = descriptor.options.find(o => o.arg === undefined);
247
if (namedOptions.length > 0 && trimmedRest.length > 0) {
249
>
const firstToken = match?.[1]?.toLowerCase();
250
>
const matched = namedOptions.find(o => o.arg?.toLowerCase() === firstToken);
251
>
if (matched) {
252
>
return { applyConfig: matched.config, strippedPrompt: (match?.[2] ?? '').trim() };
253
>
}
254
>
if (!baseOption) {
255
>
return undefined;
256
>
}
257
>
}
258
>
// Fall back to the bare command form (the base/prompt option or the sole option).
259
>
const fallback = baseOption ?? descriptor.options[0];
260
return { applyConfig: fallback.config, strippedPrompt: trimmedRest };
261
}