Add ability to specify which meta columns are listed
This commit is contained in:
@@ -481,14 +481,12 @@ fn mode_list(cmd: &mut Command, args: Args, ids: &mut Vec<i64>, tags: &Vec<Strin
|
||||
let mut item_meta: HashMap<String, String> = HashMap::new();
|
||||
|
||||
for meta in db::get_item_meta(conn, item)? {
|
||||
meta_columns.insert(meta.name.clone());
|
||||
item_meta.insert(meta.name.clone(), meta.value);
|
||||
}
|
||||
meta_by_item.insert(item_id, item_meta);
|
||||
};
|
||||
|
||||
let mut meta_columns_sorted = Vec::from_iter(meta_columns);
|
||||
meta_columns_sorted.sort();
|
||||
let meta_columns = args.options.list_meta.split(",");
|
||||
|
||||
let mut table = Table::new();
|
||||
if std::io::stdout().is_terminal() {
|
||||
@@ -506,7 +504,7 @@ fn mode_list(cmd: &mut Command, args: Args, ids: &mut Vec<i64>, tags: &Vec<Strin
|
||||
b->"Tags",
|
||||
);
|
||||
|
||||
for name in &meta_columns_sorted {
|
||||
for name in meta_columns.clone() {
|
||||
title_row.add_cell(Cell::new(name).with_style(Attr::Bold));
|
||||
}
|
||||
|
||||
@@ -535,7 +533,7 @@ fn mode_list(cmd: &mut Command, args: Args, ids: &mut Vec<i64>, tags: &Vec<Strin
|
||||
let mut table_row = Row::new(vec![id_cell,ts_cell,size_cell, compression_cell, file_size_cell, tags_cell]);
|
||||
|
||||
let item_meta = meta_by_item.get(&item_id).unwrap();
|
||||
for name in &meta_columns_sorted {
|
||||
for name in meta_columns.clone() {
|
||||
match item_meta.get(name) {
|
||||
Some(value) => table_row.add_cell(Cell::new(value)),
|
||||
None => table_row.add_cell(Cell::new(""))
|
||||
|
||||
Reference in New Issue
Block a user