|
1 | | -use crate::sdk::{Api, ApiError, block, none_if_404}; |
| 1 | +use crate::sdk::{Api, ApiError, block, block_with_wakeup, none_if_404}; |
2 | 2 | use serde::{Deserialize, Serialize}; |
3 | 3 |
|
4 | 4 | #[derive(Deserialize, Serialize)] |
@@ -99,7 +99,12 @@ struct ConnectionTypeDetail { |
99 | 99 |
|
100 | 100 | pub fn types_list(workspace_id: &str, format: &str) { |
101 | 101 | let api = Api::new(Some(workspace_id)); |
102 | | - let resp = block(api.client().connection_types().list()).unwrap_or_else(|e| e.exit()); |
| 102 | + let resp = block_with_wakeup( |
| 103 | + &api, |
| 104 | + "Loading connection types…", |
| 105 | + api.client().connection_types().list(), |
| 106 | + ) |
| 107 | + .unwrap_or_else(|e| e.exit()); |
103 | 108 | let body = ListConnectionTypesResponse { |
104 | 109 | connection_types: resp |
105 | 110 | .connection_types |
@@ -136,7 +141,12 @@ pub fn types_list(workspace_id: &str, format: &str) { |
136 | 141 |
|
137 | 142 | pub fn types_get(workspace_id: &str, name: &str, format: &str) { |
138 | 143 | let api = Api::new(Some(workspace_id)); |
139 | | - let resp = block(api.client().connection_types().get(name)).unwrap_or_else(|e| e.exit()); |
| 144 | + let resp = block_with_wakeup( |
| 145 | + &api, |
| 146 | + "Loading connection type…", |
| 147 | + api.client().connection_types().get(name), |
| 148 | + ) |
| 149 | + .unwrap_or_else(|e| e.exit()); |
140 | 150 | // The SDK models nullable fields as `Option<Option<Value>>`; flatten and |
141 | 151 | // drop an explicit JSON `null` to match the old behavior (the old struct |
142 | 152 | // deserialized a missing/`null` field to `None`). |
@@ -243,11 +253,18 @@ pub fn get(workspace_id: &str, connection_id: &str, format: &str) { |
243 | 253 | let api = Api::new(Some(workspace_id)); |
244 | 254 | let is_table = format == "table"; |
245 | 255 |
|
246 | | - let spinner = is_table.then(|| crate::util::spinner("Fetching connection...")); |
247 | | - let resp = block(api.client().connections().get(connection_id)).unwrap_or_else(|e| e.exit()); |
248 | | - if let Some(s) = spinner { |
249 | | - s.finish_and_clear(); |
| 256 | + // Keep the spinner table-only (scripting output stays clean), but route the |
| 257 | + // interactive path through the wakeup hint so a cold KEDA start is explained. |
| 258 | + let resp = if is_table { |
| 259 | + block_with_wakeup( |
| 260 | + &api, |
| 261 | + "Fetching connection...", |
| 262 | + api.client().connections().get(connection_id), |
| 263 | + ) |
| 264 | + } else { |
| 265 | + block(api.client().connections().get(connection_id)) |
250 | 266 | } |
| 267 | + .unwrap_or_else(|e| e.exit()); |
251 | 268 | let detail = ConnectionDetail { |
252 | 269 | id: resp.id, |
253 | 270 | name: resp.name, |
@@ -327,16 +344,16 @@ pub fn create(workspace_id: &str, name: &str, source_type: &str, config: &str, f |
327 | 344 | source_type.to_string(), |
328 | 345 | ); |
329 | 346 |
|
330 | | - let spinner = is_table.then(|| crate::util::spinner("Creating connection...")); |
331 | | - let resp = block(api.client().connections().create(request)).unwrap_or_else(|e| { |
332 | | - if let Some(s) = &spinner { |
333 | | - s.finish_and_clear(); |
334 | | - } |
335 | | - e.exit() |
336 | | - }); |
337 | | - if let Some(s) = &spinner { |
338 | | - s.finish_and_clear(); |
| 347 | + let resp = if is_table { |
| 348 | + block_with_wakeup( |
| 349 | + &api, |
| 350 | + "Creating connection...", |
| 351 | + api.client().connections().create(request), |
| 352 | + ) |
| 353 | + } else { |
| 354 | + block(api.client().connections().create(request)) |
339 | 355 | } |
| 356 | + .unwrap_or_else(|e| e.exit()); |
340 | 357 |
|
341 | 358 | let result = CreateResponse { |
342 | 359 | id: resp.id, |
@@ -404,7 +421,12 @@ pub fn create(workspace_id: &str, name: &str, source_type: &str, config: &str, f |
404 | 421 |
|
405 | 422 | pub fn list(workspace_id: &str, format: &str) { |
406 | 423 | let api = Api::new(Some(workspace_id)); |
407 | | - let resp = block(api.client().connections().list()).unwrap_or_else(|e| e.exit()); |
| 424 | + let resp = block_with_wakeup( |
| 425 | + &api, |
| 426 | + "Loading connections…", |
| 427 | + api.client().connections().list(), |
| 428 | + ) |
| 429 | + .unwrap_or_else(|e| e.exit()); |
408 | 430 | let body = ListResponse { |
409 | 431 | connections: resp |
410 | 432 | .connections |
|
0 commit comments