()
| 170 | } |
| 171 | |
| 172 | func NewDefaultCommandPolicyResolver() *commandInfoResolver { |
| 173 | return NewCommandInfoResolver(func(ctx context.Context, cmd Cmder) *routing.CommandPolicy { |
| 174 | module := "core" |
| 175 | command := cmd.Name() |
| 176 | cmdParts := strings.Split(command, ".") |
| 177 | if len(cmdParts) == 2 { |
| 178 | module = cmdParts[0] |
| 179 | command = cmdParts[1] |
| 180 | } |
| 181 | |
| 182 | if policy, ok := defaultPolicies[module][command]; ok { |
| 183 | return policy |
| 184 | } |
| 185 | |
| 186 | return nil |
| 187 | }) |
| 188 | } |
| 189 | |
| 190 | func (r *commandInfoResolver) GetCommandPolicy(ctx context.Context, cmd Cmder) *routing.CommandPolicy { |
| 191 | if r.resolveFunc == nil { |
no test coverage detected