aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjakobst1n <jakob.stendahl@outlook.com>2024-06-11 22:57:42 +0200
committerjakobst1n <jakob.stendahl@outlook.com>2024-06-11 22:57:42 +0200
commit2e56a0d2e80416904712514da6dab788567a719b (patch)
tree32b2c81413730ed224214f8d443456326562d6bf
parentd338982d6020e2b73a0912db048a53157ac7507e (diff)
downloadtextgraph-2e56a0d2e80416904712514da6dab788567a719b.tar.gz
textgraph-2e56a0d2e80416904712514da6dab788567a719b.zip
Rename axis argument to silent, and invert it, so axis are enabled by default
-rw-r--r--README.md3
-rw-r--r--src/graph.rs4
-rw-r--r--src/main.rs4
-rw-r--r--src/parseopts.rs16
-rw-r--r--tg.114
5 files changed, 27 insertions, 14 deletions
diff --git a/README.md b/README.md
index f0dd97a..2d4ce69 100644
--- a/README.md
+++ b/README.md
@@ -9,3 +9,6 @@ by piping data through it.
It was written because I sometimes have the need to
watch some state in a sql table for a short while.
+The documentation is in the manual file `tg.1`.
+
+
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,
};
diff --git a/tg.1 b/tg.1
index 7892d32..d6fca1d 100644
--- a/tg.1
+++ b/tg.1
@@ -3,7 +3,7 @@
tg \- TermGraph \- Text graphing utility
.SH SYNOPSIS
.B tg
-[-a|--axis] [-l|--last-n \fIN\fR] [-h|--height \fIN\fR] [-w|--width \fIN\fR] [-t \fItype\fR] [--interpolate]
+[-s|--silent] [-l|--last-n \fIN\fR] [-h|--height \fIN\fR] [-w|--width \fIN\fR] [-t \fItype\fR]
.SH DESCRIPTION
.B tg
@@ -13,8 +13,14 @@ TermGraph is a utility for graphing
.IP "\fB-h, --help\fR"
Display help information.
-.IP "\fB-a, --axis\fR"
-Enable axis on the resulting graph.
+.IP "\fB-s, --silent\fR"
+Disable distracting elements, such as axis and non-graph text.
+
+.IP "\fB-t\fR \fItype\fR"
+The type of graph to draw,
+it defaults to \fBstar\fR, which is the fastest one.
+Options are \fBstar\fR and \fBascii\fR.
+Ascii is slightly prettier to look at.
.IP "\fB-w, --width\fR \fIwidth\fR"
Specify a width for the output.
@@ -32,7 +38,7 @@ The simplest version is if you have a text file of values
.PP
.nf
.RS
-cat \fIfile\fR | tg --axis
+cat \fIfile\fR | tg
.RE
.fi
.PP