Share invocation flag lookup across installation contexts

This commit is contained in:
2026-11-22 22:24:06 +00:00
parent 3415d9337d
commit 3e4309f084
4 changed files with 78 additions and 20 deletions

View File

@@ -428,13 +428,11 @@ func featureSpellings(flag commandmeta.Flag) []capturedFlagSpelling {
}
func validateInvocationFlagCollisions(roots map[string]*canonicalNode, flags []commandmeta.Flag) error {
shared := invocationFlagSpellings(flags)
for _, node := range indexCanonicalNodes(roots) {
local := canonicalFlagSpellings(node.command)
for _, flag := range flags {
for _, spelling := range featureSpellings(flag) {
if _, exists := local[flagSpellingKey(spelling)]; exists {
return fmt.Errorf("invocation feature flag %s conflicts with command %q", spelling.token(), node.path.String())
}
for key, spelling := range canonicalFlagSpellings(node.command) {
if _, exists := shared[key]; exists {
return fmt.Errorf("invocation feature flag %s conflicts with command %q", spelling.token(), node.path.String())
}
}
}