summaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 32d5770..809c62d 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -3,6 +3,7 @@ mod parser;
pub mod user_info;
use comfy_table::Table;
+use humansize::{format_size, BINARY};
use parser::*;
use rustyline::error::ReadlineError;
use std::{io, ops::ControlFlow};
@@ -16,12 +17,24 @@ pub fn run_command(user_input: &str) -> Result<ControlFlow<(), ()>, ShackleError
Ok(ShackleCommand::Exit) => {
return Ok(ControlFlow::Break(()));
}
- Ok(ShackleCommand::List) => {
+ Ok(ShackleCommand::List(ListArgs { verbose })) => {
let mut table = Table::new();
- table.set_header(vec!["path", "description"]);
- let listing = git::list()?;
- for meta in listing {
- table.add_row(vec![meta.path.display().to_string(), meta.description]);
+ if !verbose {
+ table.set_header(vec!["path", "description"]);
+ let listing = git::list()?;
+ for meta in listing {
+ table.add_row(vec![meta.path.display().to_string(), meta.description]);
+ }
+ } else {
+ table.set_header(vec!["path", "description", "size"]);
+ let listing = git::list_verbose()?;
+ for meta in listing {
+ table.add_row(vec![
+ meta.path.display().to_string(),
+ meta.description,
+ format_size(meta.size, BINARY),
+ ]);
+ }
}
println!("{table}");