From f691c9b4c796b80387791fd383cc9c109a40e7a6 Mon Sep 17 00:00:00 2001 From: Andreas Hauser Date: Sun, 26 Dec 2021 12:55:18 +0100 Subject: [PATCH] Change --size to --geometry to avoid clashes in -s --- Cargo.toml | 2 +- README.md | 15 +++++++-------- src/bin/hist.rs | 12 ++++++------ 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e0e3bfe..eec0dbc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hist-cli" -version = "0.4.1" +version = "0.4.2" edition = "2021" authors = ["Andreas Hauser "] description = "Commandline tool for plotting frequency ranked histograms of TSV/CSV data" diff --git a/README.md b/README.md index 0a3c087..04f4924 100644 --- a/README.md +++ b/README.md @@ -10,8 +10,7 @@ export PATH="$HOME/.cargo/bin:$PATH" ## Usage ``` -$ hist --help -hist 0.4.0 +hist 0.4.2 Plots histogram of input USAGE: @@ -24,12 +23,12 @@ FLAGS: -V, --version Prints version information OPTIONS: - -T, --Title optional title above the plot [default: Counts distribution] - -o, --output <output> file to save PNG plot to [default: histogram.png] - -s, --save <save> save counts data to file as TSV, use - for STDOUT - -s, --size <size> the x and y pixel sizes of the output file [default: 1280x960] - --xdesc <xdesc> x-axis label [default: Rank] - --ydesc <ydesc> y-axis label [default: Counts] + -T, --Title <Title> optional title above the plot [default: Counts distribution] + -g, --geometry <geometry> the x and y size of the plot [default: 1280x960] + -o, --output <output> file to save PNG plot to [default: histogram.png] + -s, --save <save> save counts data to file as TSV, use - for STDOUT + --xdesc <xdesc> x-axis label [default: Rank] + --ydesc <ydesc> y-axis label [default: Counts] ARGS: <input> optional file with on entry per line [default: STDIN] diff --git a/src/bin/hist.rs b/src/bin/hist.rs index da947f9..0f33145 100644 --- a/src/bin/hist.rs +++ b/src/bin/hist.rs @@ -40,8 +40,8 @@ struct Opt Title: String, #[structopt(short, long, default_value = "1280x960")] - /// the x and y pixel sizes of the output file - size: String, + /// the x and y size of the plot + geometry: String, #[structopt(long, default_value = "Rank")] /// x-axis label @@ -141,10 +141,10 @@ fn plot_rank(sorted_counts : &Vec<usize>, opt : &Opt) -> Result<(), Box<dyn Erro let y_dim = next_potence(max as f64) as usize; let x_dim = (sorted_counts.len() as f64 * 1.1) as usize; - let (size_x_str, size_y_str) = opt.size.split_once("x").expect("size not in correct format"); - let size_x = size_x_str.parse().expect("Unable to parse size x"); - let size_y = size_y_str.parse().expect("Unable to parse size y"); - let root = BitMapBackend::new(&opt.output, (size_x, size_y)).into_drawing_area(); + let (geometry_x_str, geometry_y_str) = opt.geometry.split_once("x").expect("geometry not in correct format"); + let geometry_x = geometry_x_str.parse().expect("Unable to parse geometry x"); + let geometry_y = geometry_y_str.parse().expect("Unable to parse geometry y"); + let root = BitMapBackend::new(&opt.output, (geometry_x, geometry_y)).into_drawing_area(); root.fill(&WHITE)?;