fix: all tables respect table_config from settings

Extract shared render_item_info_table() and render_list_table() in
modes/common.rs. Update client/info, client/list, client/status,
info, status, and status_plugins to use create_table_with_config
with settings.table_config instead of hardcoded presets.

Previously only local --list used table_config; all other tables
(client modes, status, status-plugins) ignored it.
This commit is contained in:
2026-03-14 19:49:31 -03:00
parent 0bc8d9c909
commit f5bae46620
7 changed files with 181 additions and 140 deletions

View File

@@ -1,5 +1,7 @@
use crate::client::KeepClient;
use crate::modes::common::{OutputFormat, format_size, settings_output_format};
use crate::modes::common::{
DisplayListItem, OutputFormat, format_size, render_list_table, settings_output_format,
};
use clap::Command;
use log::debug;
@@ -28,31 +30,20 @@ pub fn mode(
println!("{}", serde_yaml::to_string(&items)?);
}
OutputFormat::Table => {
use comfy_table::{Table, presets::UTF8_FULL};
let mut table = Table::new();
table.load_preset(UTF8_FULL);
// Header
let headers = ["ID", "Time", "Size", "Compression", "Tags"];
table.set_header(headers.iter().map(|h| h.to_string()).collect::<Vec<_>>());
for item in &items {
let size_str = item
.size
.map(|s| format_size(s as u64, settings.human_readable))
.unwrap_or_default();
table.add_row(vec![
item.id.to_string(),
item.ts.clone(),
size_str,
item.compression.clone(),
item.tags.join(", "),
]);
}
println!("{table}");
let display_items: Vec<DisplayListItem> = items
.iter()
.map(|item| DisplayListItem {
id: item.id,
time: item.ts.clone(),
size: item
.size
.map(|s| format_size(s as u64, settings.human_readable))
.unwrap_or_default(),
compression: item.compression.clone(),
tags: item.tags.clone(),
})
.collect();
render_list_table(&display_items, &settings.table_config);
}
}