Skip to content

Commit ddf6d6a

Browse files
authored
fix: print data for get box and get styles in text mode (#1231) (#1233)
The text-mode output formatter had branches for most `get` subcommand response shapes but was missing handlers for `boundingbox` and `styles`. Both commands fell through to the default "Done" message instead of printing the returned data. Closes #1231
1 parent 5032349 commit ddf6d6a

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

cli/src/output.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,31 @@ pub fn print_response_with_opts(resp: &Response, action: Option<&str>, opts: &Ou
296296
println!("{}", count);
297297
return;
298298
}
299+
// Bounding box (get box)
300+
if action == Some("boundingbox") {
301+
if let Some(obj) = data.as_object() {
302+
let x = obj.get("x").and_then(|v| v.as_f64()).unwrap_or(0.0);
303+
let y = obj.get("y").and_then(|v| v.as_f64()).unwrap_or(0.0);
304+
let w = obj.get("width").and_then(|v| v.as_f64()).unwrap_or(0.0);
305+
let h = obj.get("height").and_then(|v| v.as_f64()).unwrap_or(0.0);
306+
println!("x: {}", x);
307+
println!("y: {}", y);
308+
println!("width: {}", w);
309+
println!("height: {}", h);
310+
}
311+
return;
312+
}
313+
// Computed styles (get styles)
314+
if let Some(styles) = data.get("styles").and_then(|v| v.as_object()) {
315+
for (key, val) in styles {
316+
let display = match val.as_str() {
317+
Some(s) => s.to_string(),
318+
None => val.to_string(),
319+
};
320+
println!("{}: {}", key, display);
321+
}
322+
return;
323+
}
299324
// Boolean results
300325
if let Some(visible) = data.get("visible").and_then(|v| v.as_bool()) {
301326
println!("{}", visible);

0 commit comments

Comments
 (0)