|
1 | 1 | use crate::color; |
2 | 2 | use crate::connection::Response; |
3 | 3 |
|
4 | | -pub fn print_response(resp: &Response, json_mode: bool) { |
| 4 | +pub fn print_response(resp: &Response, json_mode: bool, action: Option<&str>) { |
5 | 5 | if json_mode { |
6 | 6 | println!("{}", serde_json::to_string(resp).unwrap_or_default()); |
7 | 7 | return; |
@@ -135,7 +135,7 @@ pub fn print_response(resp: &Response, json_mode: bool) { |
135 | 135 | // Cleared requests |
136 | 136 | if let Some(cleared) = data.get("cleared").and_then(|v| v.as_bool()) { |
137 | 137 | if cleared { |
138 | | - println!("\x1b[32m✓\x1b[0m Request log cleared"); |
| 138 | + println!("{} Request log cleared", color::success_indicator()); |
139 | 139 | return; |
140 | 140 | } |
141 | 141 | } |
@@ -235,16 +235,44 @@ pub fn print_response(resp: &Response, json_mode: bool) { |
235 | 235 | return; |
236 | 236 | } |
237 | 237 | } |
238 | | - // Screenshot path (no "started", "frames", or download fields) |
239 | | - if let Some(path) = data.get("path").and_then(|v| v.as_str()) { |
240 | | - println!("{} Screenshot saved to {}", color::success_indicator(), color::green(path)); |
241 | | - return; |
242 | | - } |
243 | 238 | // Screenshot base64 |
244 | 239 | if let Some(base64) = data.get("base64").and_then(|v| v.as_str()) { |
245 | 240 | println!("{}", base64); |
246 | 241 | return; |
247 | 242 | } |
| 243 | + // Path-based operations (screenshot/pdf/trace/har/download/state/video) |
| 244 | + if let Some(path) = data.get("path").and_then(|v| v.as_str()) { |
| 245 | + match action.unwrap_or("") { |
| 246 | + "screenshot" => println!("{} Screenshot saved to {}", color::success_indicator(), color::green(path)), |
| 247 | + "pdf" => println!("{} PDF saved to {}", color::success_indicator(), color::green(path)), |
| 248 | + "trace_stop" => println!("{} Trace saved to {}", color::success_indicator(), color::green(path)), |
| 249 | + "har_stop" => println!("{} HAR saved to {}", color::success_indicator(), color::green(path)), |
| 250 | + "download" | "waitfordownload" => println!("{} Download saved to {}", color::success_indicator(), color::green(path)), |
| 251 | + "video_stop" => println!("{} Video saved to {}", color::success_indicator(), color::green(path)), |
| 252 | + "state_save" => println!("{} State saved to {}", color::success_indicator(), color::green(path)), |
| 253 | + "state_load" => { |
| 254 | + if let Some(note) = data.get("note").and_then(|v| v.as_str()) { |
| 255 | + println!("{}", note); |
| 256 | + } |
| 257 | + println!("{} State path set to {}", color::success_indicator(), color::green(path)); |
| 258 | + } |
| 259 | + // video_start and other commands that provide a path with a note |
| 260 | + "video_start" => { |
| 261 | + if let Some(note) = data.get("note").and_then(|v| v.as_str()) { |
| 262 | + println!("{}", note); |
| 263 | + } |
| 264 | + println!("Path: {}", path); |
| 265 | + } |
| 266 | + _ => println!("{} Saved to {}", color::success_indicator(), color::green(path)), |
| 267 | + } |
| 268 | + return; |
| 269 | + } |
| 270 | + |
| 271 | + // Informational note |
| 272 | + if let Some(note) = data.get("note").and_then(|v| v.as_str()) { |
| 273 | + println!("{}", note); |
| 274 | + return; |
| 275 | + } |
248 | 276 | // Default success |
249 | 277 | println!("{} Done", color::success_indicator()); |
250 | 278 | } |
|
0 commit comments