From 1a9b46180fa1e796f2ed0bf965141490900ec77e Mon Sep 17 00:00:00 2001 From: "jakob.stendahl" Date: Mon, 17 Jun 2024 09:08:15 +0200 Subject: Don't use the tg alias by default, add fedora build script --- README.md | 75 +++++++++++++++++++++------------------- packaging/FEDORA/textgraph.spec | 17 +++------ packaging/package-debian.sh | 4 +-- packaging/package-fedora.sh | 33 ++++++++++++++++++ textgraph.1 | 76 +++++++++++++++++++++++++++++++++++++++++ tg.1 | 76 ----------------------------------------- 6 files changed, 155 insertions(+), 126 deletions(-) create mode 100755 packaging/package-fedora.sh create mode 100644 textgraph.1 delete mode 100644 tg.1 diff --git a/README.md b/README.md index ed15be4..b70679b 100644 --- a/README.md +++ b/README.md @@ -9,22 +9,24 @@ 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`. +The documentation is in the manual file `textgraph.1`. It is only tested with glibc and terminals with ansi escape code support. ## Usage -You can compile it with `cargo build --release`, -there is also a script in `packaging` which can be used to make a `.deb`. +There is a script in `packaging` which can be used to make a `.deb`. If you are on a debian based distro, you should be able to run `./packaging/package-debian.sh`. Then a `textgraph.deb` file should be made somewhere in `/tmp/`. -There is a spec file for rpms as well, but I haven't gotten around to making a script to build for that. +There is a script in `packaging` which can be used to make a `.rpm`. +If you are on a rpm based distro, you should be able to run `./packaging/package-fedora.sh`. +Then a `textgraph-.rpm` should be build in `~/rpmbuild/RPMS/x86_64/`. +You can compile it with `cargo build --release`. If you compile with `cargo build --release`, you can copy it to your path, e.g. ``` -sudo install target/release/textgraph /usr/local/bin/tg -sudo install tg.1 /usr/share/man/man1/tg.1 +sudo install target/release/textgraph /usr/local/bin/textgraph +sudo install textgraph.1 /usr/share/man/man1/textgraph.1 ``` ## Example 1 @@ -113,76 +115,77 @@ Example of a simple sinusoid ## Manual For reference, this is a translation of the manual page. -Best is to check to manual page itself, not the README `man -l tg.1`. +Best is to check to manual page itself, not the README `man -l textgraph.1`. ``` -TG(1) General Commands Manual TG(1) - - +TEXTGRAPH(1) General Commands Manual TEXTGRAPH(1) name - tg - TermGraph - Text graphing utility + TextGraph - Text graphing utility SYNOPSIS - tg [-s|--silent] [-l|--last-n N] [-h|--height N] [-w|--width N] [-t - type] - + textgraph [OPTIONS] [input_file] DESCRIPTION - tg TermGraph is a utility for graphing - + textgraph TermGraph is a utility for graphing OPTIONS - -h, --help - Display help information. - + --help Display help information. -s, --silent Disable distracting elements, such as axis and non-graph text. + -n, --last-n count + If specified, only the newest count samples will be plotted. + This can be useful if you want to follow the latest state of a + graph that is piped in. + + -c, --cut + This is a special case of --last-n. Where the number of columns + --width will be used for the count. -a, --ascii Shorthand for -t ascii, if multiple options setting mode is specified, the last will likely be respected. - -b, --braille Shorthand for -t braille, if multiple options setting mode is specified, the last will likely be respected. + -t star|ascii|braille|braille6|braille8 + The type of graph to draw, it defaults to star, which is the + fastest one. - -n, --last-n count - If specified, only the newest count samples will be plotted. - This can be useful if you want to follow the latest state of a - graph that is piped in. + star Scatter plot using only the '*' character. + ascii Ascii is slightly prettier to look at. - -c, --cut - This is a special case of --last-n. Where the number of columns - --width will be used for the count. - - - -t type - The type of graph to draw, it defaults to star, which is the - fastest one. Options are star, ascii and braille. Ascii is - slightly prettier to look at. + braille, braille6 Uses braille characters to draw higher resolu‐ + tion plots. + braille8 This is the most scatter-plot-ish with the highest res‐ + olution, but also the most buggy. -w, --width width Specify a width for the output. If not specified, it will at‐ tempt to determine the TTY width and use that. If it cannot be automatically determined, it will fail. - -h, --height height Specify a height for the output. If not specified, it will at‐ tempt to determine the TTY height and use that. If it cannot be automatically determined, it will fail. + --color yes|no + Enable or disable colors, by default color will be enabled if it + looks like a tty is connected. + + It can therefore be nice to use --color yes if you are piping + the output into another program that supports colors. EXAMPLES The simplest version is if you have a text file of values - cat file | tg + cat file | textgraph - 2024-06-08 TG(1) + 2024-06-08 TEXTGRAPH(1) ``` diff --git a/packaging/FEDORA/textgraph.spec b/packaging/FEDORA/textgraph.spec index 0873f69..2a92c6a 100644 --- a/packaging/FEDORA/textgraph.spec +++ b/packaging/FEDORA/textgraph.spec @@ -15,10 +15,11 @@ Version: %{package_version} Release: %{package_release} Summary: Text graphing utility -#License: GPLv3 +License: GPLv3 Source: %{name}-%{version}.tar.gz BuildRequires: cargo-rpm-macros >= 24 +BuildRequires: rust-libc-devel %description Text graphing utility @@ -28,21 +29,13 @@ Text graphing utility %cargo_prep %build -# This is not best practice, but it was somewhat annoying to actually get all -# dependencies vendored/packaged properly. -# currently this app doesn't have any cargo dependencies, but keeping it for reference -#sed -i '/^\[source\.crates-io\]/,/^$/d' %{cargo_config} -#sed -i '/^\[source\.local-registry\]/,/^$/d' %{cargo_config} -#sed -i '/^\[net\]/,/^$/d' %{cargo_config} -#echo "[net]" >> %{cargo_config} -#echo "git-fetch-with-cli = true" >> %{cargo_config} %cargo_build %install %cargo_install mkdir -p %{buildroot}%{_mandir}/man1 -install tg.1 %{buildroot}%{_mandir}/man1/tg.1 +install textgraph.1 %{buildroot}%{_mandir}/man1/textgraph.1 %if %{with check} %check @@ -51,8 +44,8 @@ install tg.1 %{buildroot}%{_mandir}/man1/tg.1 %files %doc README.md -%{_bindir}/tg -%{_mandir}/man1/tg.1.gz +%{_bindir}/textgraph +%{_mandir}/man1/textgraph.1.gz %changelog %autochangelog diff --git a/packaging/package-debian.sh b/packaging/package-debian.sh index 3bea609..51d3962 100755 --- a/packaging/package-debian.sh +++ b/packaging/package-debian.sh @@ -17,8 +17,8 @@ mandir=${dir}/usr/share/man/man1 mkdir -p ${mandir} cp -r packaging/DEBIAN ${dir}/DEBIAN -cp target/release/textgraph ${bindir}/tg -cp tg.1 ${mandir}/tg.1 +cp target/release/textgraph ${bindir}/textgraph +cp textgraph.1 ${mandir}/textgraph.1 cd ${tmpdir} dpkg-deb --build textgraph diff --git a/packaging/package-fedora.sh b/packaging/package-fedora.sh new file mode 100755 index 0000000..d91c018 --- /dev/null +++ b/packaging/package-fedora.sh @@ -0,0 +1,33 @@ +#!/bin/bash +set -x + +DIST=fc40 +ARCH=x86_64 +RPMBUILD=rpmbuild +BUILDROOT=${HOME}/rpmbuild/ +SPECFILE=packaging/FEDORA/textgraph.spec +SOURCEDIR=$(pwd) +VERSION=$(awk -F ' = ' '$1 ~ /version/ { gsub(/[\"]/, "", $2); printf("%s",$2) }' Cargo.toml) +BUILDROOT_SPECFILE="${BUILDROOT}/SPECS/textgraph.spec" + +rpmdev-setuptree + +echo "Making tarball" +tarwd=$(dirname "${SOURCEDIR}") +tarfile=$(basename "${SOURCEDIR}") +tar -czf "textgraph-${VERSION}.tar.gz" -C "${tarwd}" --transform "s|${tarfile}|textgraph-${VERSION}|" ${tarfile} +cp "textgraph-${VERSION}.tar.gz" "${BUILDROOT}/SOURCES/textgraph-${VERSION}.tar.gz" + +echo "Copy specfile" +cp "${SPECFILE}" "${BUILDROOT_SPECFILE}" + + +echo "Install dependencies" +sudo dnf builddep "${BUILDROOT_SPECFILE}" + +echo "Running spmbuild" +rpmbuild -ba "${BUILDROOT_SPECFILE}" \ + --define "package_version ${VERSION}" \ + --define "package_release 1.${DIST}" + + diff --git a/textgraph.1 b/textgraph.1 new file mode 100644 index 0000000..58f3702 --- /dev/null +++ b/textgraph.1 @@ -0,0 +1,76 @@ +.TH TEXTGRAPH 1 2024-06-08 +.SH name +TextGraph \- Text graphing utility +.SH SYNOPSIS +.B textgraph [OPTIONS] [\fIinput_file\fB] + +.SH DESCRIPTION +.B textgraph +TermGraph is a utility for graphing + +.SH OPTIONS +.IP "\fB--help\fR" +Display help information. + +.IP "\fB-s, --silent\fR" +Disable distracting elements, such as axis and non-graph text. + +.IP "\fB-n, --last-n\fR \fIcount\fR" +If specified, only the newest \fIcount\fR samples will be plotted. +This can be useful if you want to follow the latest state of a graph that is piped in. + +.IP "\fB-c, --cut\fR" +This is a special case of \fB--last-n\fR. Where the number of columns +\fB--width\fI will be used for the count. + +.IP "\fB-a, --ascii\fR" +Shorthand for -t ascii, if multiple options setting mode is specified, +the last will likely be respected. + +.IP "\fB-b, --braille\fR" +Shorthand for -t braille, if multiple options setting mode is specified, +the last will likely be respected. + +.IP "\fB-t\fR \fIstar\fR|\fIascii\fR|\fIbraille\fR|\fIbraille6\fR|\fIbraille8\fR" +The type of graph to draw, +it defaults to \fBstar\fR, which is the fastest one. + +\fBstar\fR +Scatter plot using only the '*' character. + +\fBascii\fR +Ascii is slightly prettier to look at. + +\fBbraille\fR, +\fBbraille6\fR +Uses braille characters to draw higher resolution plots. + +\fBbraille8\fR +This is the most scatter-plot-ish with the highest resolution, but also the most buggy. + +.IP "\fB-w, --width\fR \fIwidth\fR" +Specify a width for the output. +If not specified, it will attempt to determine the TTY width and use that. +If it cannot be automatically determined, it will fail. + +.IP "\fB-h, --height\fR \fIheight\fR" +Specify a height for the output. +If not specified, it will attempt to determine the TTY height and use that. +If it cannot be automatically determined, it will fail. + +.IP "\fB--color\fR \fIyes\fR|\fIno\fR" +Enable or disable colors, by default color will be enabled if it looks like a tty is connected. + +It can therefore be nice to use \fB--color yes\fR +if you are piping the output into another program that supports colors. + +.SH EXAMPLES + +The simplest version is if you have a text file of values +.PP +.nf +.RS +cat \fIfile\fR | textgraph +.RE +.fi +.PP diff --git a/tg.1 b/tg.1 deleted file mode 100644 index ff0eb3b..0000000 --- a/tg.1 +++ /dev/null @@ -1,76 +0,0 @@ -.TH TG 1 2024-06-08 -.SH name -tg \- TermGraph \- Text graphing utility -.SH SYNOPSIS -.B tg [OPTIONS] [\fIinput_file\fB] - -.SH DESCRIPTION -.B tg -TermGraph is a utility for graphing - -.SH OPTIONS -.IP "\fB--help\fR" -Display help information. - -.IP "\fB-s, --silent\fR" -Disable distracting elements, such as axis and non-graph text. - -.IP "\fB-n, --last-n\fR \fIcount\fR" -If specified, only the newest \fIcount\fR samples will be plotted. -This can be useful if you want to follow the latest state of a graph that is piped in. - -.IP "\fB-c, --cut\fR" -This is a special case of \fB--last-n\fR. Where the number of columns -\fB--width\fI will be used for the count. - -.IP "\fB-a, --ascii\fR" -Shorthand for -t ascii, if multiple options setting mode is specified, -the last will likely be respected. - -.IP "\fB-b, --braille\fR" -Shorthand for -t braille, if multiple options setting mode is specified, -the last will likely be respected. - -.IP "\fB-t\fR \fIstar\fR|\fIascii\fR|\fIbraille\fR|\fIbraille6\fR|\fIbraille8\fR" -The type of graph to draw, -it defaults to \fBstar\fR, which is the fastest one. - -\fBstar\fR -Scatter plot using only the '*' character. - -\fBascii\fR -Ascii is slightly prettier to look at. - -\fBbraille\fR, -\fBbraille6\fR -Uses braille characters to draw higher resolution plots. - -\fBbraille8\fR -This is the most scatter-plot-ish with the highest resolution, but also the most buggy. - -.IP "\fB-w, --width\fR \fIwidth\fR" -Specify a width for the output. -If not specified, it will attempt to determine the TTY width and use that. -If it cannot be automatically determined, it will fail. - -.IP "\fB-h, --height\fR \fIheight\fR" -Specify a height for the output. -If not specified, it will attempt to determine the TTY height and use that. -If it cannot be automatically determined, it will fail. - -.IP "\fB--color\fR \fIyes\fR|\fIno\fR" -Enable or disable colors, by default color will be enabled if it looks like a tty is connected. - -It can therefore be nice to use \fB--color yes\fR -if you are piping the output into another program that supports colors. - -.SH EXAMPLES - -The simplest version is if you have a text file of values -.PP -.nf -.RS -cat \fIfile\fR | tg -.RE -.fi -.PP -- cgit v1.2.3