resolveDeclaredShortcutScopes returns the scopes declared by a mounted shortcut command for the given identity.
(cmd *cobra.Command, identity string)
| 73 | // resolveDeclaredShortcutScopes returns the scopes declared by a mounted |
| 74 | // shortcut command for the given identity. |
| 75 | func resolveDeclaredShortcutScopes(cmd *cobra.Command, identity string) []string { |
| 76 | if cmd == nil || cmd.Parent() == nil || !strings.HasPrefix(cmd.Name(), "+") { |
| 77 | return nil |
| 78 | } |
| 79 | |
| 80 | service := cmd.Parent().Name() |
| 81 | for _, sc := range shortcuts.AllShortcuts() { |
| 82 | if sc.Service != service || sc.Command != cmd.Name() || !shortcutSupportsIdentity(sc, identity) { |
| 83 | continue |
| 84 | } |
| 85 | scopes := sc.DeclaredScopesForIdentity(identity) |
| 86 | if len(scopes) == 0 { |
| 87 | return nil |
| 88 | } |
| 89 | return append([]string(nil), scopes...) |
| 90 | } |
| 91 | return nil |
| 92 | } |
| 93 | |
| 94 | // resolveDeclaredServiceMethodScopes returns the scopes declared by a |
| 95 | // service/resource/method command. It reconstructs the catalog path from the |
no test coverage detected