Skip to content

Commit

Permalink
make bw the default option for easy pipes
Browse files Browse the repository at this point in the history
  • Loading branch information
alexhallam committed Jul 20, 2021
1 parent 21607a7 commit 96c405a
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tidy-viewer"
version = "0.0.2"
version = "0.0.3"
authors = ["alexhallam <[email protected]>"]
edition = "2018"
description = "Head, but for csvs and with color"
Expand Down
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ The following will install from the [crates.io](https://crates.io/crates/tidy-vi
cargo install tidy-viewer
```

For convenience add the alas `alias tv='tidy-viewer'` to bashrc.

```
echo `alias tv='tidy-viewer'` >> `~/.bashrc`
```

2. Install from source

Expand All @@ -25,12 +30,14 @@ The current version is alpha. I do not plan to push to crates.io until this is m
1. Clone repo
2. `cargo build --release`
3. cp binary to `bin`
4. Add `alias tv='tidy-viewer'` to `~/.bashrc`

```
git clone https://github.com/alexhallam/tv
cd tv
cargo build --release
sudo cp ./target/release/tv /usr/local/bin/.
echo `alias tv='tidy-viewer'` >> `~/.bashrc`
```

# Example
Expand Down Expand Up @@ -62,7 +69,7 @@ Print only the first three digits. The first three digits represent > 99.9% the
[q](https://github.com/zestyping/q) - Command line csv data manipulation query-like. Python

[miller](https://github.com/johnkerl/miller) - Commane line data manipulaiton, statistics, and more. C
=======

[xsv](https://github.com/BurntSushi/xsv) - a command line program for indexing, slicing, analyzing, splitting and joining CSV files

[tsv-utils](https://github.com/eBay/tsv-utils) - command line utilities for tabular data files
Expand Down
2 changes: 2 additions & 0 deletions a.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
asdf
asdf
68 changes: 62 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ struct Cli {
#[structopt(
short = "c",
long = "color",
default_value = "1",
help = "There are 4 colors (1)nord, (2)one_dark, (3)gruvbox, and (4)dracula."
default_value = "0",
help = "There are 4 colors (1)nord, (2)one_dark, (3)gruvbox, and (4)dracula. Note that colors will make it difficult to pipe output to other utilities"
)]
color: usize,
#[structopt(
Expand All @@ -36,8 +36,8 @@ struct Cli {
)]
footer: String,
#[structopt(
short = "r",
long = "rows",
short = "n",
long = "number of rows to output",
default_value = "25",
help = "Show how many rows to display. Default 25"
)]
Expand Down Expand Up @@ -159,7 +159,6 @@ fn main() {
vf[i] = datatype::trunc_strings(v[i].clone(), col_largest_width[i]);
} else if vec_datatypes[i] == "<dbl>" {
vf[i] = datatype::trunc_strings(v[i].clone(), col_largest_width[i]);
println!("{:?}",vf[i]);
} else {
vf[i] = datatype::trunc_strings(v[i].clone(), col_largest_width[i]);
}
Expand All @@ -173,9 +172,65 @@ fn main() {
}
}

if color_option < 1 {
let meta_text = "tv dim:";
let div = "x";
print!("{: <6}", "");
println!(
"{} {} {} {}",
meta_text,
(rows - 1),
div,
cols,
);
if !datatype::is_na(&title_option.to_string()) {
print!("{: <6}", "");
println!(
"{}",
title_option
);
}
print!("{: <6}", "");
for col in 0..cols {
let text = vp[0].get(col).unwrap().to_string();
print!("{}",text);
}
println!();
for row in 1..rows {
print!(
"{: <6}",
(row)
);
for col in 0..cols {
let text = vp[row].get(col).unwrap().to_string();
let tmp;
print!(
"{}",
if datatype::is_na_string_padded(vp[row].get(col).unwrap().to_string()) {
tmp = text;
tmp
} else {
tmp = text;
tmp
}
);
}
println!();
}
if !datatype::is_na(&footer_option.to_string()) {
print!("{: <6}", "");
println!(
"{}",
footer_option
);
}

println!();
}//end if
else{
// color
let meta_text = "tv dim:";
let div = "x";
// meta
print!("{: <6}", "");
println!(
"{} {} {} {}",
Expand Down Expand Up @@ -250,6 +305,7 @@ fn main() {
}

println!();
}//end color else
} // end main

#[cfg(test)]
Expand Down

0 comments on commit 96c405a

Please sign in to comment.