Capture and validate invocation features
This commit is contained in:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user