diff options
author | jakobst1n <jakob.stendahl@outlook.com> | 2024-06-11 22:57:42 +0200 |
---|---|---|
committer | jakobst1n <jakob.stendahl@outlook.com> | 2024-06-11 22:57:42 +0200 |
commit | 2e56a0d2e80416904712514da6dab788567a719b (patch) | |
tree | 32b2c81413730ed224214f8d443456326562d6bf /src | |
parent | d338982d6020e2b73a0912db048a53157ac7507e (diff) | |
download | textgraph-2e56a0d2e80416904712514da6dab788567a719b.tar.gz textgraph-2e56a0d2e80416904712514da6dab788567a719b.zip |
Rename axis argument to silent, and invert it, so axis are enabled by default
Diffstat (limited to 'src')
-rw-r--r-- | src/graph.rs | 4 | ||||
-rw-r--r-- | src/main.rs | 4 | ||||
-rw-r--r-- | src/parseopts.rs | 16 |
3 files changed, 14 insertions, 10 deletions
diff --git a/src/graph.rs b/src/graph.rs index a3a8909..85a0838 100644 --- a/src/graph.rs +++ b/src/graph.rs @@ -150,6 +150,8 @@ impl GraphBuilder { if self.enable_axis { self.draw_axis( + min_y, + max_y, GraphPixel::Normal(ASCII_1), GraphPixel::Normal(ASCII_0), GraphPixel::Normal('└'), @@ -245,6 +247,8 @@ impl GraphBuilder { /// * `c7` - Top right axis pixel fn draw_axis( &mut self, + min_y: f64, + max_y: f64, c1: GraphPixel<char>, c2: GraphPixel<char>, c3: GraphPixel<char>, diff --git a/src/main.rs b/src/main.rs index 35ca9f7..728f42a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -26,7 +26,7 @@ fn filter(opts: Opts) { x_values.push(i); let mut gb = graph::GraphBuilder::new(&x_values, &y_values, opts.width, opts.height); - gb.axis(opts.axis); + gb.axis(!opts.silent); gb.graph_type(opts.graph_type.clone()); if let Some(n) = opts.last_n { gb.keep_tail(n as usize); @@ -58,7 +58,7 @@ fn graph_file(opts: Opts) { } let mut gb = graph::GraphBuilder::new(&x_values, &y_values, opts.width, opts.height); - gb.axis(opts.axis); + gb.axis(!opts.silent); gb.graph_type(opts.graph_type); if let Some(n) = opts.last_n { gb.keep_tail(n as usize); diff --git a/src/parseopts.rs b/src/parseopts.rs index 5368a87..1bae188 100644 --- a/src/parseopts.rs +++ b/src/parseopts.rs @@ -9,8 +9,8 @@ pub struct Opts { pub height: usize, /// Which type of graph it should be, ascii, star pub graph_type: GraphType, - /// Enable axis on the resulting graph, makes it a bit prettier - pub axis: bool, + /// This will disable distracting elements, such as axis + pub silent: bool, /// Specify if it is used as a filter, and you only want to look at the last N samples pub last_n: Option<u64>, /// Read from the specified file, instead of reading continously from stdin @@ -25,8 +25,8 @@ pub struct OptsBuilder { pub height: Option<usize>, /// Which type of graph it should be, ascii, star pub graph_type: GraphType, - /// Enable axis on the resulting graph, makes it a bit prettier - pub axis: bool, + /// This will disable distracting elements, such as axis + pub silent: bool, /// Specify if it is used as a filter, and you only want to look at the last N samples pub last_n: Option<u64>, /// Read from the specified file, instead of reading continously from stdin @@ -53,7 +53,7 @@ impl OptsBuilder { } }), graph_type: self.graph_type, - axis: self.axis, + silent: self.silent, last_n: self.last_n, in_file: self.in_file, } @@ -127,8 +127,8 @@ pub fn parseopt(opts: &mut OptsBuilder, arg: &str, value: Option<String>, progna }; opts.last_n = Some(last_n); } - "a" | "axis" => { - opts.axis = true; + "s" | "silent" => { + opts.silent = true; } "w" | "width" => { let Some(width) = value else { @@ -158,7 +158,7 @@ pub fn parseopts() -> Opts { width: None, height: None, graph_type: GraphType::Star, - axis: false, + silent: false, last_n: None, in_file: None, }; |