mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-24 05:31:11 +00:00
* fix(cli): filter Commander value placeholders from Fish completion flags The Fish completion generator was treating Commander.js value placeholders (like <path|->, <file>, [optional]) as command-line tokens, causing the angle-bracket values to be interpreted as shell redirects when the completion script was sourced. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(cli): use parsed option flags for completions Co-authored-by: 丁宇婷0668001435 <ding.yuting@xydigit.com> * fix(cli): support long option aliases in Fish completion Co-authored-by: 丁宇婷0668001435 <ding.yuting@xydigit.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> Co-authored-by: Peter Steinberger <steipete@gmail.com> Co-authored-by: Peter Steinberger <peter@steipete.me>
30 lines
936 B
TypeScript
30 lines
936 B
TypeScript
// Fish completion line builders for subcommands and options.
|
|
function escapeFishDescription(value: string): string {
|
|
return value.replace(/'/g, "'\\''");
|
|
}
|
|
|
|
export function buildFishSubcommandCompletionLine(params: {
|
|
rootCmd: string;
|
|
condition: string;
|
|
name: string;
|
|
description: string;
|
|
}): string {
|
|
const desc = escapeFishDescription(params.description);
|
|
return `complete -c ${params.rootCmd} -n "${params.condition}" -a "${params.name}" -d '${desc}'\n`;
|
|
}
|
|
|
|
export function buildFishOptionCompletionLine(params: {
|
|
rootCmd: string;
|
|
condition: string;
|
|
flags: readonly string[];
|
|
description: string;
|
|
}): string {
|
|
const desc = escapeFishDescription(params.description);
|
|
let line = `complete -c ${params.rootCmd} -n "${params.condition}"`;
|
|
for (const flag of params.flags) {
|
|
line += flag.startsWith("--") ? ` -l ${flag.slice(2)}` : ` -s ${flag.slice(1)}`;
|
|
}
|
|
line += ` -d '${desc}'\n`;
|
|
return line;
|
|
}
|