(requestOpts ...management.RequestOption)
| 1109 | } |
| 1110 | |
| 1111 | func (c *cli) appPickerOptions(requestOpts ...management.RequestOption) pickerOptionsFunc { |
| 1112 | requestOpts = append(requestOpts, management.Parameter("is_global", "false")) |
| 1113 | |
| 1114 | return func(ctx context.Context) (pickerOptions, error) { |
| 1115 | clientList, err := c.api.Client.List(ctx, requestOpts...) |
| 1116 | if err != nil { |
| 1117 | return nil, fmt.Errorf("failed to list applications: %w", err) |
| 1118 | } |
| 1119 | |
| 1120 | tenant, err := c.Config.GetTenant(c.tenant) |
| 1121 | if err != nil { |
| 1122 | return nil, err |
| 1123 | } |
| 1124 | |
| 1125 | var priorityOpts, opts pickerOptions |
| 1126 | for _, client := range clientList.Clients { |
| 1127 | value := client.GetClientID() |
| 1128 | label := fmt.Sprintf( |
| 1129 | "%s [%s] %s", |
| 1130 | client.GetName(), |
| 1131 | display.ApplyColorToFriendlyAppType(display.FriendlyAppType(client.GetAppType())), |
| 1132 | ansi.Faint("("+value+")"), |
| 1133 | ) |
| 1134 | option := pickerOption{value: value, label: label} |
| 1135 | |
| 1136 | if tenant.DefaultAppID == client.GetClientID() { |
| 1137 | priorityOpts = append(priorityOpts, option) |
| 1138 | } else { |
| 1139 | opts = append(opts, option) |
| 1140 | } |
| 1141 | } |
| 1142 | |
| 1143 | if len(opts)+len(priorityOpts) == 0 { |
| 1144 | return nil, errNoApps |
| 1145 | } |
| 1146 | |
| 1147 | return append(priorityOpts, opts...), nil |
| 1148 | } |
| 1149 | } |
| 1150 | |
| 1151 | // Session Transfer. |
| 1152 | func appsSessionTransferCmd(cli *cli) *cobra.Command { |
no test coverage detected