Capture and validate invocation features

This commit is contained in:
2026-11-22 20:52:04 +00:00
parent 68515668de
commit ea3ce25001
8 changed files with 276 additions and 2 deletions

View File

@@ -67,7 +67,7 @@ func (spelling capturedFlagSpelling) token() string {
func compileFlagAliases(rules []RoutingRule, roots map[string]*canonicalNode, aliases interface {
Resolve(commandpath.Path) commandpath.Path
ProperSourcePrefixes() []commandpath.Path
}) (map[string]resolvedFlagAliases, map[string]resolvedFlagAliases, error) {
}, features []commandmeta.Flag) (map[string]resolvedFlagAliases, map[string]resolvedFlagAliases, error) {
canonicalNodes := indexCanonicalNodes(roots)
global := make(map[string]flagAliasMapping)
scoped := make(map[string]map[string]flagAliasMapping)
@@ -97,6 +97,15 @@ func compileFlagAliases(rules []RoutingRule, roots map[string]*canonicalNode, al
canonicalContexts[key] = flagAliasContext{path: node.path.Clone(), canonical: canonicalFlagSpellings(node.command)}
}
discoveryContexts := discoverFlagContexts(rules, roots, aliases, canonicalNodes)
for _, contexts := range []map[string]flagAliasContext{canonicalContexts, discoveryContexts} {
for _, context := range contexts {
for _, flag := range features {
for _, spelling := range featureSpellings(flag) {
context.canonical[flagSpellingKey(spelling)] = spelling
}
}
}
}
canonicalKeys := sortedContextKeys(canonicalContexts)
resolvedCanonical := make(map[string]resolvedFlagAliases, len(canonicalContexts))