diff options
author | Justin Wernick <justin@worthe-it.co.za> | 2023-07-03 21:54:21 +0200 |
---|---|---|
committer | Justin Wernick <justin@worthe-it.co.za> | 2023-07-03 21:54:21 +0200 |
commit | e18a928db5916fce43c35dff585072dace0da7e0 (patch) | |
tree | d33c8d6c08a779b0f28ddff83ce540b3821160e4 /src/lib.rs | |
parent | ff05e4ab91b3b84ffb04b3d8089052112e7bd51c (diff) |
Added a new "--verbose" option to the list command
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 23 |
1 files changed, 18 insertions, 5 deletions
@@ -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}"); |