table

Помоћни програм из командне линије за форматирање и приказ CSV-а
Дневник | Датотеке | Референце | ПРОЧИТАЈМЕ | ЛИЦЕНЦА

чување 937c30eca3f3ddaf24b1df0dc8c077eb6b1560c2
родитељ c4b66d942e602aff159343d1023c1d630358e821
Аутор: Страхиња Радић <contact@strahinja.org>
Датум:   Fri, 12 Feb 2021 20:55:31 +0100

Switched to apenwarr/redo

Signed-off-by: Страхиња Радић <contact@strahinja.org>

Diffstat:
M.gitignore | 10++++++++++
DMakefile | 37-------------------------------------
Aall.do | 3+++
Aclean.do | 3+++
Adate.do | 4++++
Adefault.do | 11+++++++++++
Adefault.gz.do | 3+++
Adefault.o.do | 3+++
Adefault.pdf.do | 3+++
Ainstall.do | 10++++++++++
Arebuild.do | 3+++
Dtable.1 | 156-------------------------------------------------------------------------------
Atable.1.in | 156+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Atable.do | 3+++
Aversion.do | 7+++++++
измењених датотека: 15, додавања: 219(+), брисања: 193(-)

diff --git a/.gitignore b/.gitignore @@ -1,3 +1,8 @@ +.cache +.redo +*.session +.do_built +.do_built.dir *~ *.bak *.orig @@ -6,7 +11,12 @@ *.pdf *.ps *.swp +*.did nohup.out *.png table +table.1 *.gz +date +version + diff --git a/Makefile b/Makefile @@ -1,37 +0,0 @@ -BINDIR=/usr/local/bin -MANDIR=/usr/local/share/man/man1 -CFLAGS= -#CFLAGS=-g - -all: table table.1.gz doc - -.o: .c - $(CC) $(CFLAGS) -o $@ -c $< - -%.gz: % - gzip -kf $< - -%.ps: %.1 - groff -mandoc -t -T ps $< > $@ - -%.pdf: %.1 - groff -mandoc -t -T pdf $< > $@ - -table: table.o - $(CC) $(CFLAGS) -lunistring -o $@ $< - -doc: table.pdf - -install: all - mkdir -p $(BINDIR) $(MANDIR) - cp table $(BINDIR) - cp table.1.gz $(MANDIR) - -uninstall: - rm $(BINDIR)/table $(MANDIR)/table.1.gz 2>/dev/null - -clean: table.o table table.1.gz table.pdf - rm $^ 2>/dev/null - -.PHONY: clean all doc install uninstall - diff --git a/all.do b/all.do @@ -0,0 +1,3 @@ +redo-ifchange table +redo-ifchange table.1.gz table.pdf + diff --git a/clean.do b/clean.do @@ -0,0 +1,3 @@ +redo-always +rm -f table table.1 table.1.gz *.o *~ *.pdf + diff --git a/date.do b/date.do @@ -0,0 +1,4 @@ +LC_ALL=C date +'%d %b %Y' >$3 +redo-always +redo-stamp <$3 + diff --git a/default.do b/default.do @@ -0,0 +1,11 @@ +if [ -r $1.in ]; then + redo-ifchange $1.in version date + read VERSION <version + read DATE <date + sed -e "s/%VERSION%/$VERSION/g" \ + -e "s/%DATE%/$DATE/g" <$1.in +else + echo "$0: don't know how to build '$1'" >&2 + exit 99 +fi + diff --git a/default.gz.do b/default.gz.do @@ -0,0 +1,3 @@ +redo-ifchange $2 +gzip -cf $2 >$3 + diff --git a/default.o.do b/default.o.do @@ -0,0 +1,3 @@ +redo-ifchange $2.c +${TABLE_CC:-gcc} -g -Wall -std=c99 -o $3 -c $2.c + diff --git a/default.pdf.do b/default.pdf.do @@ -0,0 +1,3 @@ +redo-ifchange $2.1 +groff -mandoc -t -T pdf $2.1 >$3 + diff --git a/install.do b/install.do @@ -0,0 +1,10 @@ +redo-ifchange all +PREFIX=/usr/local +BINDIR=$PREFIX/bin +DOCDIR=$PREFIX/share/doc/table +MANDIR=$PREFIX/share/man/man1 +install -d $BINDIR $DOCDIR $MANDIR +install -m 0755 table $BINDIR +install -m 0644 table.pdf $DOCDIR +install -m 0644 table.1.gz $MANDIR + diff --git a/rebuild.do b/rebuild.do @@ -0,0 +1,3 @@ +redo clean +redo all + diff --git a/table.1 b/table.1 @@ -1,156 +0,0 @@ -'\" t -.\" Manpage for table(1) -. -.mso an-ext.tmac -. -.TH TABLE "1" "27 Oct 2020" "table v0.1.2-beta" "General Commands Manual" -.SH NAME -table \- Command line utility to format and display CSV. -. -.SH SYNOPSIS -.SY table -.RI [ options ] -.RI [ filename ] -.YS -. -.SH COPYRIGHT -table Copyright \(co 2020 Strahinya Radich. -. -.SH DESCRIPTION -.B Table -is a command line utility to format and display -.SM CSV. -It parses the given file or standard input as -.SM CSV -and prints out a table using Unicode characters for box -drawing. -. -.SH OPTIONS -. -.TP -.B \-a -.TQ -.B \-\-ansi -.br -.SM ANSI SGR -processing in the input: add -.EX -.in +4 -\\e[0m\\e[?25h -.in -4 -.EE -to the end of each cell. (Also see -.SM -.B "BUGS " -below.) -. -.TP -.B \-b -.TQ -.B \-\-border-mode -.br -Border mode: force single column. -. -.TP -.BR \-c " <\fIcols\fR>" -.TQ -.BR \-\-columns= <\fIcols\fR> -.br -Set maximum table width in columns (default 80). -. -.TP -.BR \-d " <\fIdelim\fR>" -.TQ -.BR \-\-delimiter= <\fIdelim\fR> -.br -Set field delimiter (default ","). First line of the input determines the number -of table columns. Special characters, like ";", need to be quoted: -.EX -.in +4 -$ table -d ';' -.in -4 -.EE -. -.TP -.BR \-h -.TQ -.B \-\-help -.br -Print this usage information screen. -. -.TP -.BR \-s " <\fIset\fR>" -.TQ -.BR \-\-symbols= <\fIset\fR> -.br -Use table symbol set <\fIset\fR> for table lines, where <\fIset\fR> is one of -the following (format: <\fIborder\fR><\fIinner border\fR>): -.TS -box tab(@); -c l. -\fIaa\fR@ascii-ascii, -_ -\fIss\fR@single-single, -_ -\fIsd\fR@single-double, -_ -\fIds\fR@double-single (default), -_ -\fIdd\fR@double-double. -.TE -. -.TP -.B \-v -.TQ -.B \-\-version -.br -Print program version and exit. -. -.SH "SEE ALSO" -.BR awk (1), -.BR sed (1) -. -.SH EXAMPLES -. -.TP -.EX -$ watch "table /proc/loadavg -d ' ' -c 50 -s ss" -.EE -Periodically display -.SM CPU -load information in a single-line table -. -.TP -.EX -$ ls -l | tail -n +2 | sed -e 's/ \+/ /g' | table -d ' ' -.EE -Format a long list of files in the current directory in a double line table with -single-line column divisors -. -.TP -.EX -$ ls -l | tail -n +2 | awk '{ print $1 " " $9 }' | table -d ' ' -c 30 -.EE -Like the above, but only permissions and file names are printed in a narrow -table -. -.SH BUGS -. -.PP -.SM ANSI -sequences are not handled as well as they should as of -.B table -v0.1.2 and the code to format them will likely be rewritten. They are displayed -to an extent, together with the codes to reset the formatting, but the line and -column lengths are still not correctly determined. -. -.PP -For more details, see the -.SM TODO -file in the repository. -. -.PP -Bugs can be reported using the Github issue tracker at: -.UR https://\:github.com/\:Strahinja/\:table/\:issues -.UE - diff --git a/table.1.in b/table.1.in @@ -0,0 +1,156 @@ +'\" t +.\" Manpage for table(1) +. +.mso an-ext.tmac +. +.TH TABLE "1" "%DATE%" "%VERSION%" "General Commands Manual" +.SH NAME +table \- Command line utility to format and display CSV. +. +.SH SYNOPSIS +.SY table +.RI [ options ] +.RI [ filename ] +.YS +. +.SH COPYRIGHT +table Copyright \(co 2020 Strahinya Radich. +. +.SH DESCRIPTION +.B Table +is a command line utility to format and display +.SM CSV. +It parses the given file or standard input as +.SM CSV +and prints out a table using Unicode characters for box +drawing. +. +.SH OPTIONS +. +.TP +.B \-a +.TQ +.B \-\-ansi +.br +.SM ANSI SGR +processing in the input: add +.EX +.in +4 +\\e[0m\\e[?25h +.in -4 +.EE +to the end of each cell. (Also see +.SM +.B "BUGS " +below.) +. +.TP +.B \-b +.TQ +.B \-\-border-mode +.br +Border mode: force single column. +. +.TP +.BR \-c " <\fIcols\fR>" +.TQ +.BR \-\-columns= <\fIcols\fR> +.br +Set maximum table width in columns (default 80). +. +.TP +.BR \-d " <\fIdelim\fR>" +.TQ +.BR \-\-delimiter= <\fIdelim\fR> +.br +Set field delimiter (default ","). First line of the input determines the number +of table columns. Special characters, like ";", need to be quoted: +.EX +.in +4 +$ table -d ';' +.in -4 +.EE +. +.TP +.BR \-h +.TQ +.B \-\-help +.br +Print this usage information screen. +. +.TP +.BR \-s " <\fIset\fR>" +.TQ +.BR \-\-symbols= <\fIset\fR> +.br +Use table symbol set <\fIset\fR> for table lines, where <\fIset\fR> is one of +the following (format: <\fIborder\fR><\fIinner border\fR>): +.TS +box tab(@); +c l. +\fIaa\fR@ascii-ascii, +_ +\fIss\fR@single-single, +_ +\fIsd\fR@single-double, +_ +\fIds\fR@double-single (default), +_ +\fIdd\fR@double-double. +.TE +. +.TP +.B \-v +.TQ +.B \-\-version +.br +Print program version and exit. +. +.SH "SEE ALSO" +.BR awk (1), +.BR sed (1) +. +.SH EXAMPLES +. +.TP +.EX +$ watch "table /proc/loadavg -d ' ' -c 50 -s ss" +.EE +Periodically display +.SM CPU +load information in a single-line table +. +.TP +.EX +$ ls -l | tail -n +2 | sed -e 's/ \+/ /g' | table -d ' ' +.EE +Format a long list of files in the current directory in a double line table with +single-line column divisors +. +.TP +.EX +$ ls -l | tail -n +2 | awk '{ print $1 " " $9 }' | table -d ' ' -c 30 +.EE +Like the above, but only permissions and file names are printed in a narrow +table +. +.SH BUGS +. +.PP +.SM ANSI +sequences are not handled as well as they should as of +.B table +v0.1.2 and the code to format them will likely be rewritten. They are displayed +to an extent, together with the codes to reset the formatting, but the line and +column lengths are still not correctly determined. +. +.PP +For more details, see the +.SM TODO +file in the repository. +. +.PP +Bugs can be reported using the Github issue tracker at: +.UR https://\:github.com/\:Strahinja/\:table/\:issues +.UE + diff --git a/table.do b/table.do @@ -0,0 +1,3 @@ +redo-ifchange table.o table.c defs.h +${TABLE_CC:-gcc} -g -Wall -std=c99 -o $3 table.o -lunistring + diff --git a/version.do b/version.do @@ -0,0 +1,7 @@ +if ! git describe >$3; then + echo "$0: can't call git describe; falling back to 'unknown'" >&2 + echo 'unknown' >$3 +fi +redo-always +redo-stamp <$3 +