torvyn_cli/output/
table.rs1use crate::output::OutputContext;
6use tabled::{Table, Tabled};
7
8#[allow(dead_code)]
12pub fn render_table<T: Tabled>(ctx: &OutputContext, items: &[T]) {
13 if items.is_empty() {
14 return;
15 }
16 let table = Table::new(items);
17 let table_str = table.to_string();
18
19 for line in table_str.lines() {
20 eprintln!(" {line}");
21 }
22 let _ = ctx;
23}
24
25fn display_option(o: &Option<String>) -> String {
27 o.clone().unwrap_or_default()
28}
29
30#[derive(Debug, Tabled, serde::Serialize)]
32#[allow(dead_code)]
33pub struct DoctorCheckRow {
34 #[tabled(rename = "Check")]
36 pub check: String,
37 #[tabled(rename = "Status")]
39 pub status: String,
40 #[tabled(rename = "Detail")]
42 pub detail: String,
43 #[tabled(rename = "Fix", display_with = "display_option")]
45 #[serde(skip_serializing_if = "Option::is_none")]
46 pub fix: Option<String>,
47}
48
49#[derive(Debug, Tabled, serde::Serialize)]
51#[allow(dead_code)]
52pub struct InterfaceRow {
53 #[tabled(rename = "Direction")]
55 pub direction: String,
56 #[tabled(rename = "Interface")]
58 pub interface: String,
59}