diff --git a/Cargo.lock b/Cargo.lock index 9270300..c24184e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -138,6 +138,26 @@ dependencies = [ "memchr", ] +[[package]] +name = "directories" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f51c5d4ddabd36886dd3e1438cb358cdcb0d7c499cb99cb4ac2e38e18b5cb210" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "dirs-sys" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03d86534ed367a67548dc68113a0f5db55432fdfbb6e6f9d77704397d95d5780" +dependencies = [ + "libc", + "redox_users", + "winapi", +] + [[package]] name = "either" version = "1.6.1" @@ -150,6 +170,17 @@ version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" +[[package]] +name = "getrandom" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + [[package]] name = "heck" version = "0.3.2" @@ -356,6 +387,16 @@ dependencies = [ "bitflags", ] +[[package]] +name = "redox_users" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64" +dependencies = [ + "getrandom", + "redox_syscall", +] + [[package]] name = "regex" version = "1.4.6" @@ -399,6 +440,20 @@ name = "serde" version = "1.0.125" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "558dc50e1a5a5fa7112ca2ce4effcb321b0300c0d4ccf0776a9f60cd89031171" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.125" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b093b7a2bb58203b5da3056c05b4ec1fed827dcfdb37347a8841695263b3d06d" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] [[package]] name = "signal-hook" @@ -512,17 +567,29 @@ dependencies = [ "console", "crossterm", "csv", + "directories", "itertools", "lazy_static", "linecount", "owo-colors", "pad", "regex", + "serde", "structopt", "tabwriter", + "toml", "unicode-truncate", ] +[[package]] +name = "toml" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa" +dependencies = [ + "serde", +] + [[package]] name = "unicode-segmentation" version = "1.7.1" @@ -562,6 +629,12 @@ version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" +[[package]] +name = "wasi" +version = "0.10.2+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" + [[package]] name = "winapi" version = "0.3.9" diff --git a/Cargo.toml b/Cargo.toml index d6d2a30..abefcda 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,12 +29,15 @@ section = "utility" console = "0.14.1" crossterm = "0.20.0" csv = "1.1.6" +directories = "4.0" itertools = "0.10.0" lazy_static = "1.4.0" linecount = "0.1.0" owo-colors = "1.3.0" pad = "0.1" regex = "1.4.5" +serde = {version = "1.0", features = ["derive"]} structopt = "0.3.21" tabwriter = "1.2.1" +toml = "0.5" unicode-truncate = "0.2.0" diff --git a/README.md b/README.md index 16fbdf0..4131274 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ [![Rust](https://github.com/alexhallam/tv/actions/workflows/rust.yml/badge.svg)](https://github.com/alexhallam/tv/actions/workflows/rust.yml) [![Crate](https://img.shields.io/crates/v/tidy-viewer.svg)](https://crates.io/crates/tidy-viewer) +![Crates.io](https://img.shields.io/crates/d/tidy-viewer?label=creates.io%20downloads) +![GitHub all releases](https://img.shields.io/github/downloads/alexhallam/tv/total?label=github%20release%20downloads)

Tidy Viewer (tv)

Tidy Viewer (tv) is a cross-platform csv pretty printer that uses column styling to maximize viewer enjoyment.

@@ -10,6 +12,14 @@ ![example](img/starwars.png) +# Contents +* [Installation](#installation) +* [Examples](#examples) +* [Significant Figure Definitions & Rules](#significant-figure-definitions-and-rules) +* [Tools to pair with `tv`](#tools-to-pair-with-tv) +* [Configuration Dotfile](#configuration-dotfile) (Coming Soon!) +* [Help](#help) +* [Inspiration](#inspiration) # Installation @@ -120,7 +130,7 @@ wget https://raw.githubusercontent.com/datasciencedojo/datasets/master/titanic.c tv titanic.csv ``` -# Significant Figure Definitions & Rules +# Significant Figure Definitions And Rules ![example](img/sigs.png) @@ -268,6 +278,10 @@ In cases where the terminal width can't fit all of the columns in a dataframe, c ![overflow](img/pigeon-racing.png) +# Configuration Dotfile + +For information on dotfile configuration see `tv --help`. This allows users to set their own color palette, rows to print, max column width, etc. + # Help `tv --help` @@ -278,10 +292,40 @@ Tidy Viewer (tv) is a csv pretty printer that uses column styling to maximize vi Example Usage: wget https://raw.githubusercontent.com/tidyverse/ggplot2/master/data-raw/diamonds.csv - cat diamonds.csv | head -n 35 | tv + tv diamonds.csv + + Configuration File Support: + An example config is printed to make it easy to copy/paste to `tv.toml`. + The config (tv.toml) location is dependent on OS: + * Linux: $XDG_CONFIG_HOME or $HOME/.config/tv.toml + * macOS: $HOME/Library/Application Support/tv.toml + * Windows: {FOLDERID_RoamingAppData}\tv.toml + + ## ==Tidy-Viewer Config Example== + ## Remove the first column of comments for valid toml file + ## The delimiter separating the columns. [default: ,] + #delimiter = "," + ## Add a title to your tv. Example 'Test Data' [default: NA ("")] + #title = "" + ## Add a footer to your tv. Example 'footer info' [default: NA ("")] + #footer = "" + ## The upper (maxiumum) width of columns. [default: 20] + #upper_column_width = 20 + ## The minimum width of columns. Must be 2 or larger. [default: 2] + #lower_column_width = 2 + ## head number of rows to output [default: 25] + #number = 35 + ## 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 + #header_color = [232, 168, 124] + ## std_color = [R,G,B] color for standard cell data values + #std_color = [133, 205, 202] + ## na_color = [R,G,B] color for NA values + #na_color = [226, 125, 95] USAGE: - tv [FLAGS] [OPTIONS] [FILE] + tidy-viewer [FLAGS] [OPTIONS] [FILE] FLAGS: -d, --debug-mode Print object details to make it easier for the maintainer to find and resolve bugs. @@ -290,10 +334,17 @@ FLAGS: OPTIONS: -c, --color - There are 4 colors (1)nord, (2)one_dark, (3)gruvbox, and (4)dracula. An input of (0)bw will remove color - properties. Note that colors will make it difficult to pipe output to other utilities [default: 1] + There are 5 preconfigured color palettes: + (1)nord + (2)one_dark + (3)gruvbox + (4)dracula + (5)uncolor (Coming Soon) + An input of (5)uncolor will remove color properties. Note that colors will make it difficult to pipe output + to other utilities.The default value of (0) is reserved to make config/option coloring logic easier. + [default: 0] -s, --delimiter The delimiter separating the columns. [default: ,] - -f, --footer