(program: CommanderCommand)
| 519 | } |
| 520 | |
| 521 | function generateFishCompletion(program: CommanderCommand): string { |
| 522 | const map = new Map<string, CompletionNode>() |
| 523 | collectCompletionTree(program, [], map) |
| 524 | |
| 525 | const subcommandsCase = buildFishSwitchBody(map, node => node.subcommands) |
| 526 | const optionsCase = buildFishSwitchBody(map, node => node.options) |
| 527 | const valueOptionsCase = buildFishSwitchBody(map, node => node.valueOptions) |
| 528 | |
| 529 | return `function __claude_subcommands |
| 530 | ${subcommandsCase} |
| 531 | end |
| 532 | |
| 533 | function __claude_options |
| 534 | ${optionsCase} |
| 535 | end |
| 536 | |
| 537 | function __claude_value_options |
| 538 | ${valueOptionsCase} |
| 539 | end |
| 540 | |
| 541 | function __claude_candidates |
| 542 | set -l tokens (commandline -opc) |
| 543 | set -e tokens[1] |
| 544 | set -l path |
| 545 | set -l pending_value 0 |
| 546 | |
| 547 | for token in $tokens |
| 548 | set -l key (string join ' ' $path) |
| 549 | |
| 550 | if test $pending_value -eq 1 |
| 551 | set pending_value 0 |
| 552 | continue |
| 553 | end |
| 554 | |
| 555 | if string match -qr '^-' -- $token |
| 556 | set -l option_name (string split -m1 '=' -- $token)[1] |
| 557 | set -l value_options (__claude_value_options "$key") |
| 558 | if not string match -qr '=' -- $token |
| 559 | if contains -- $option_name $value_options |
| 560 | set pending_value 1 |
| 561 | end |
| 562 | end |
| 563 | continue |
| 564 | end |
| 565 | |
| 566 | set -l subcommands (__claude_subcommands "$key") |
| 567 | if contains -- $token $subcommands |
| 568 | set path $path $token |
| 569 | continue |
| 570 | end |
| 571 | |
| 572 | break |
| 573 | end |
| 574 | |
| 575 | if test $pending_value -eq 1 |
| 576 | return 0 |
| 577 | end |
| 578 |
no test coverage detected