Compose discovery help through group aliases
This commit is contained in:
13
route.go
13
route.go
@@ -40,10 +40,10 @@ func resolveEnteredRoute(args []string, snapshot *routingSnapshot) routeResult {
|
||||
case len(path) == 0:
|
||||
result.kind = routeCanonical
|
||||
default:
|
||||
if discovery, ok := findDiscoveryPath(snapshot.discoveryFlags, path); ok && len(discovery) == len(path) {
|
||||
if discovery, ok := findDiscoveryPath(snapshot.discoveryFlags, resolved, path); ok {
|
||||
result.kind = routeDiscovery
|
||||
result.discoveryPath = discovery
|
||||
result.enteredPath = discovery.Clone()
|
||||
result.enteredPath = path.Clone()
|
||||
result.args = commandpath.CloneTokens(trailing)
|
||||
} else if trace.operandOwner != nil {
|
||||
result.kind = routeCanonical
|
||||
@@ -89,11 +89,10 @@ func enteredEndpoint(path commandpath.Path, origins [][]int, canonicalLength int
|
||||
return path[:inputLength].Clone()
|
||||
}
|
||||
|
||||
func findDiscoveryPath(contexts map[string]resolvedFlagAliases, path commandpath.Path) (commandpath.Path, bool) {
|
||||
for length := len(path); length > 0; length-- {
|
||||
prefix := path[:length]
|
||||
if _, exists := contexts[prefix.Key()]; exists {
|
||||
return prefix.Clone(), true
|
||||
func findDiscoveryPath(contexts map[string]resolvedFlagAliases, paths ...commandpath.Path) (commandpath.Path, bool) {
|
||||
for _, path := range paths {
|
||||
if _, exists := contexts[path.Key()]; len(path) > 0 && exists {
|
||||
return path.Clone(), true
|
||||
}
|
||||
}
|
||||
return nil, false
|
||||
|
||||
Reference in New Issue
Block a user