diff --git a/CHANGELOG.md b/CHANGELOG.md index f3e28c7..8998b59 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +1.4.4 (2021-11-18) +================== + +* **Feature 1** Added -e flag to extend rows (don't truncate). + +This new version gives a flag option to extend rows rather than truncate. This is especially useful for wide csv files that would overflow the terminal width. When using the extend mode, pipe output to `less -S` to enables scrolling right and left with arrow keys. + 1.4.3 (2021-11-17) ================== diff --git a/Cargo.toml b/Cargo.toml index cde0495..44a77f8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,7 @@ license = "Unlicense/MIT" name = "tidy-viewer" readme = "README.md" repository = "https://github.com/alexhallam/tv" -version = "1.4.3" +version = "1.4.4" [package.metadata.deb] assets = [ diff --git a/README.md b/README.md index 2355b53..d1f936a 100644 --- a/README.md +++ b/README.md @@ -310,7 +310,7 @@ For information on dotfile configuration see `tv --help`. This allows users to s `tv --help` ```txt -tv 1.4.3 +tv 1.4.4 Tidy Viewer (tv) is a csv pretty printer that uses column styling to maximize viewer enjoyment.✨✨📺✨✨ Example Usage: @@ -338,6 +338,8 @@ Tidy Viewer (tv) is a csv pretty printer that uses column styling to maximize vi #lower_column_width = 2 ## head number of rows to output [default: 25] #number = 35 + ## extend rows beyond term width (do not trucate) [default: false] + # extend_rows = true ## meta_color = [R,G,B] color for row index and "tv dim: rowsxcols" #meta_color = [64, 179, 162] ## header_color = [R,G,B] color for column headers @@ -354,6 +356,7 @@ USAGE: FLAGS: -d, --debug-mode Print object details to make it easier for the maintainer to find and resolve bugs. + -e, --extend-rows Extended row beyond term width (do not truncate). Useful with `less -S`. -a, --color-always Always force color output. Example `tv -a starwars.csv | less -R` or `tv -a starwars.csv | bat -p`. The `less` cli has the `-R` flag to parse colored output. -h, --help Prints help information diff --git a/src/main.rs b/src/main.rs index 243008b..11fe4c0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -43,6 +43,8 @@ use toml; #lower_column_width = 2 ## head number of rows to output [default: 25] #number = 35 + ## extend rows beyond term width (do not trucate) [default: false] + # extend_rows = true ## meta_color = [R,G,B] color for row index and \"tv dim: rowsxcols\" #meta_color = [64, 179, 162] ## header_color = [R,G,B] color for column headers @@ -117,6 +119,12 @@ struct Cli { help = "Significant Digits. Default 3. Max is 7" )] sigfig: i64, + #[structopt( + short = "e", + long = "extend-rows", + help = "Extended row beyond term width (do not truncate). Useful with `less -S`." + )] + extend: bool, #[structopt( short = "d", long = "debug-mode", @@ -144,6 +152,7 @@ fn main() { upper_column_width: usize, lower_column_width: usize, number: usize, + extend_rows: bool, meta_color: toml::value::Array, header_color: toml::value::Array, std_color: toml::value::Array, @@ -157,12 +166,12 @@ fn main() { let conf_file = PathBuf::from("tv.toml"); let conf_dir_file: PathBuf = config_dir.join(conf_file.clone()); let file_contents: Option = std::fs::read_to_string(conf_dir_file).ok(); - //println!("file_contents {:?}", file_contents); + // println!("file_contents {:?}", file_contents); let config: Option = match file_contents { Some(x) => toml::from_str(&x.to_owned()).ok(), None => None, }; - //println!("config {:#?}", config); + // println!("config {:#?}", config); let term_tuple = size().unwrap(); let opt = Cli::from_args(); @@ -178,6 +187,7 @@ fn main() { let is_row_display_defined = !(opt.row_display == 25); let is_tty = atty::is(atty::Stream::Stdout); let is_force_color = opt.force_color; + let extend_option = opt.extend || config.as_ref().map(|d| d.extend_rows).unwrap_or(false); let title_option = match (&config, is_title_defined) { (Some(x), false) => &x.title, @@ -401,7 +411,11 @@ fn main() { vp.push(row); } - let num_cols_to_print = get_num_cols_to_print(cols, vp.clone(), term_tuple); + let num_cols_to_print = if extend_option { + cols + } else { + get_num_cols_to_print(cols, vp.clone(), term_tuple) + }; // color let meta_text = "tv dim:";