diff options
author | Joel Kronqvist <joelkronqvist@proton.me> | 2024-04-14 10:30:26 +0300 |
---|---|---|
committer | Joel Kronqvist <joel.kronqvist@iki.fi> | 2024-04-15 10:24:56 +0300 |
commit | 6c4ec5c0bd46b1292d15a789560fb5acd813bbce (patch) | |
tree | ba459e6914f6e37e6e89d97c8eedadbc8c65a210 | |
parent | ba5dd828bde07493ef5f2f8abf6921e0a040133d (diff) | |
download | stdu-6c4ec5c0bd46b1292d15a789560fb5acd813bbce.tar.gz stdu-6c4ec5c0bd46b1292d15a789560fb5acd813bbce.zip |
Added installation and `-O3` in Makefile, created manpage and README and licensed under the MIT license
-rw-r--r-- | LICENSE.txt | 7 | ||||
-rw-r--r-- | Makefile | 35 | ||||
-rw-r--r-- | README | 29 | ||||
-rw-r--r-- | stdu.1 | 51 |
4 files changed, 115 insertions, 7 deletions
diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..09648f9 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,7 @@ +Copyright © 2024 Joel Kronqvist + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -1,25 +1,46 @@ +BINPATH = /usr/local/bin +MANPATH = /usr/local/share/man + stdu : stdu.o intmath.o intmath.h config-parser.h config-parser.o formatting.o \ formatting.h - cc -g -o stdu stdu.o intmath.o config-parser.o formatting.o + cc -lm -O3 -o stdu stdu.o intmath.o config-parser.o formatting.o stdu.o : stdu.c - cc -g -c stdu.c + cc -O3 -c stdu.c formatting.o : formatting.h formatting.c intmath.h intmath.c minitest.h - cc -g -c formatting.c + cc -O3 -c formatting.c intmath.o : intmath.c minitest.h intmath.h - cc -g -c intmath.c + cc -O3 -c intmath.c config-parser.o : config-parser.c config-parser.h minitest.h - cc -g -c config-parser.c + cc -O3 -c config-parser.c tests : tests.c minitest.h intmath.c config-parser.c formatting.c - cc -g -o tests tests.c + cc -lm -O3 -o tests tests.c test : tests ./tests + +.PHONY: clean cleanall install uninstall + +install : stdu + mkdir -p ${BINPATH} + cp -f stdu ${BINPATH} + chmod 755 ${BINPATH}/stdu + mkdir -p ${MANPATH}/man1 + cp -f stdu.1 ${MANPATH}/man1 + chmod 644 ${MANPATH}/man1/stdu.1 + +uninstall : + -rm -f ${BINPATH}/stdu + -rm -f ${MANPATH}/man1/stdu.1 + clean : - rm stdu stdu.o intmath.o tests config-parser.o formatting.o + -rm stdu.o intmath.o tests config-parser.o formatting.o + +cleanall: clean + -rm stdu @@ -0,0 +1,29 @@ + +stdu README +=========== + +`stdu` is a program for monitoring the amount of +input data in real time. + + +Building +-------- + +Build the binary `stdu` by running `make`. A +compiler and standard C libraries are required. + +Installation +------------ + +Install by either copying/symlinking `stdu` and +`stdu.1` to the appropriate locations, or run +`make install`. You can change the installation +paths by modifying `BINPATH` and `MANPATH` in the +makefile. + +Usage +----- + +See the man page and help message: +`stdu --help` +`man stdu` @@ -0,0 +1,51 @@ +.Dd 2024-04-14 +.Dt STDU 1 +.Sh NAME +.Nm stdu +.Nd monitor amount of data read from stdin +.Sh SYNOPSIS +.Nm stdu +.Op Fl Fl help +.Op Fl Fl human-readable +.Op Fl Fl multiline +.Op Fl Fl precision Ar n +.Nm stdu +.Op Fl hm? +.Op Fl p Ar n +.Sh DESCRIPTION +.Nm +reads data from standard input and prints in real time the amount of data +read. +.Nm +always prints the amount of data read as precisely as specified. Thus it +has to read byte by byte (resulting to slow operation compared to reading +in chunks) if \fB--precision\fR or \fB--human-readable\fR aren't specified, +so specifying them is recommended. +.Sh OPTIONS +.Bl -tag -width 3n +.It Fl Fl help | Fl ? +Displays a help message. +.It Fl Fl human-readable | Fl h +Outputs in human-readable format. Uses binary prefixes by default +(Ki, Mi, Gi, ...). SI prefixes (K, M, G, ...) are used instead if +\fB--precision\fR is specified. +.It Fl Fl multiline | Fl m +Output with line breaks. +.Nm +outputs on one line by default. +.It Fl Fl precision Ar n | Fl p Ar n | \fB-p\fIn\fR +Output with +.Ar n +significant digits. +.Nm +may add trailing zeroes. +.El +.Sh EXAMPLES +.Nm +is useful as a progress bar replacement when transmitting large files. +.Bd -literal +nc -l 1234 | tee backup.tar.gz | stdu -p3 -h +.Ed +.Sh "SEE ALSO" +.Xr du 1 + |