MCPcopy Create free account
hub / github.com/Noumena-Network/code / generateFishCompletion

Function generateFishCompletion

src/cli/handlers/ant.ts:521–586  ·  view source on GitHub ↗
(program: CommanderCommand)

Source from the content-addressed store, hash-verified

519}
520
521function 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}
531end
532
533function __claude_options
534${optionsCase}
535end
536
537function __claude_value_options
538${valueOptionsCase}
539end
540
541function __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

Callers 1

generateCompletionScriptFunction · 0.85

Calls 2

collectCompletionTreeFunction · 0.85
buildFishSwitchBodyFunction · 0.85

Tested by

no test coverage detected