Index completion metadata by canonical node

This commit is contained in:
2026-11-03 13:13:20 +00:00
parent 5227049de6
commit f4ed4c4839
5 changed files with 25 additions and 18 deletions

View File

@@ -99,13 +99,13 @@ func (a *App) buildRoutingSnapshot() *routingSnapshot {
sort.Strings(names)
var key commandmeta.Key
for _, name := range names {
root.Children = append(root.Children, bridgeCommand(a.commands[name].command, snapshot, &key))
root.Children = append(root.Children, bridgeCommand(snapshot.canonical[name], snapshot, &key))
}
return snapshot
}
func bridgeCommand(command Command, snapshot *routingSnapshot, next *commandmeta.Key) *commandmeta.Command {
record := command.record
func bridgeCommand(node *canonicalNode, snapshot *routingSnapshot, next *commandmeta.Key) *commandmeta.Command {
record := node.command.record
*next = *next + 1
declaration := &commandmeta.Command{
Key: *next,
@@ -114,6 +114,7 @@ func bridgeCommand(command Command, snapshot *routingSnapshot, next *commandmeta
Description: record.description,
CoreFlags: commandmeta.ReportingFlags(),
}
node.metadata = declaration
if record.payload != nil {
snapshot.runners[declaration.Key] = record.payload
declaration.Runnable = record.payload.hasRun()
@@ -126,7 +127,7 @@ func bridgeCommand(command Command, snapshot *routingSnapshot, next *commandmeta
if child.record == nil || child.record.absent {
continue
}
declaration.Children = append(declaration.Children, bridgeCommand(child, snapshot, next))
declaration.Children = append(declaration.Children, bridgeCommand(node.children[child.record.name], snapshot, next))
}
return declaration
}