Keep command routing independent of operand counts
This commit is contained in:
25
route.go
25
route.go
@@ -37,22 +37,23 @@ func resolveEnteredRoute(args []string, snapshot *routingSnapshot) routeResult {
|
||||
case trace.exact != nil:
|
||||
result.kind = routeCanonical
|
||||
result.canonicalPath = trace.exact.path.Clone()
|
||||
case trace.operandOwner != nil:
|
||||
case len(path) == 0:
|
||||
result.kind = routeCanonical
|
||||
result.canonicalPath = trace.operandOwner.path.Clone()
|
||||
default:
|
||||
if discovery, ok := findDiscoveryPath(snapshot.discoveryFlags, path); ok && len(discovery) == len(path) {
|
||||
result.kind = routeDiscovery
|
||||
result.discoveryPath = discovery
|
||||
result.enteredPath = discovery.Clone()
|
||||
result.args = commandpath.CloneTokens(trailing)
|
||||
} else if trace.operandOwner != nil {
|
||||
result.kind = routeCanonical
|
||||
result.canonicalPath = trace.operandOwner.path.Clone()
|
||||
} else {
|
||||
result.enteredPath = path.Clone()
|
||||
}
|
||||
}
|
||||
|
||||
if result.kind == routeCanonical {
|
||||
result.enteredPath = enteredEndpoint(path, origins, len(result.canonicalPath))
|
||||
} else if len(path) == 0 {
|
||||
result.kind = routeCanonical
|
||||
} else if discovery, ok := findDiscoveryPath(snapshot.discoveryFlags, path); ok && len(discovery) == len(path) {
|
||||
result.kind = routeDiscovery
|
||||
result.discoveryPath = discovery
|
||||
result.enteredPath = discovery.Clone()
|
||||
result.args = commandpath.CloneTokens(trailing)
|
||||
} else {
|
||||
result.enteredPath = path.Clone()
|
||||
}
|
||||
|
||||
if result.kind != routeDiscovery {
|
||||
|
||||
Reference in New Issue
Block a user