From 485b36ce0247a9ed6b3e23e0385079c1e92034d7 Mon Sep 17 00:00:00 2001 From: "Andrew Phillips (aider)" Date: Tue, 13 May 2025 17:55:48 -0300 Subject: [PATCH] feat: add digest type and value to info output --- src/modes/info.rs | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/src/modes/info.rs b/src/modes/info.rs index 5c89f18..99ab8e9 100644 --- a/src/modes/info.rs +++ b/src/modes/info.rs @@ -108,12 +108,19 @@ pub fn mode_info( file_size_cell, ])); - let compression_engine = - get_compression_engine(compression_type).expect("Unable to get compression engine"); - let magic = compression_engine.magic(item_path.clone()); + let file_magic_cell = match compression_type { + Ok(compression_type) => { + let compression_engine = + get_compression_engine(compression_type).expect("Unable to get compression engine"); + let magic = compression_engine.magic(item_path.clone()); - let file_magic_cell = match magic { - Ok(magic) => Cell::new(magic.as_str()), + match magic { + Ok(magic) => Cell::new(magic.as_str()), + Err(e) => Cell::new(&e.to_string()) + .with_style(Attr::ForegroundColor(prettytable::color::RED)) + .with_style(Attr::Bold), + } + }, Err(e) => Cell::new(&e.to_string()) .with_style(Attr::ForegroundColor(prettytable::color::RED)) .with_style(Attr::Bold), @@ -129,6 +136,20 @@ pub fn mode_info( Cell::new(&item_tags.join(" ")), ])); + if let Some(digest_type) = &item.digest_type { + table.add_row(Row::new(vec![ + Cell::new("Digest Type").with_style(Attr::Bold), + Cell::new(digest_type), + ])); + } + + if let Some(digest_value) = &item.digest_value { + table.add_row(Row::new(vec![ + Cell::new("Digest Value").with_style(Attr::Bold), + Cell::new(digest_value), + ])); + } + for meta in crate::db::get_item_meta(conn, &item)? { let meta_name = format!("Meta: {}", &meta.name); table.add_row(Row::new(vec![