чување 3adf0a1522b33f2171d49ced3e07af09f34f03a6
родитељ c137857a30f885577c232ceb23038307aebaa408
Аутор: Страхиња Радић <contact@strahinja.org>
Датум: Fri, 30 Oct 2020 23:10:49 +0100
table.1: Optimized example code, -s options into tbl; Makefile: Added rules for table.pdf
Diffstat:
| M | Makefile | | | 18 | +++++++++++++----- |
| M | table.1 | | | 125 | ++++++++++++++++++++++++++++++++++++++++--------------------------------------- |
измењених датотека: 2, додавања: 76(+), брисања: 67(-)
diff --git a/Makefile b/Makefile
@@ -3,17 +3,25 @@ MANDIR=/usr/local/share/man/man1
CFLAGS=
#CFLAGS=-g
-all: table table.1.gz
+all: table table.1.gz doc
.o: .c
$(CC) $(CFLAGS) -o $@ -c $<
%.gz: %
- gzip -k $<
+ 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)
@@ -22,8 +30,8 @@ install: all
uninstall:
rm $(BINDIR)/table $(MANDIR)/table.1.gz 2>/dev/null
-clean: table.o table table.1.gz
- rm table.o table table.1.gz 2>/dev/null
+clean: table.o table table.1.gz table.pdf
+ rm $^ 2>/dev/null
-.PHONY: clean all install uninstall
+.PHONY: clean all doc install uninstall
diff --git a/table.1 b/table.1
@@ -1,14 +1,21 @@
+'\" 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
-.B table
+.SY table
.RI [ options ]
.RI [ filename ]
+.YS
+.
.SH COPYRIGHT
-table Copyright (C) 2020 Strahinya Radich.
+table Copyright \(co 2020 Strahinya Radich.
+.
.SH DESCRIPTION
.B Table
is a command line utility to format and display
@@ -17,120 +24,115 @@ 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
-.PD 0
-.BR \-a
-.TP
-.PD
+.B \-a
+.TQ
.B \-\-ansi
-.br
.SM ANSI SGR
processing in the input: add
+.EX
.in +4
-.ft CB
\\e[0m\\e[?25h
-.ft R
.in -4
+.EE
to the end of each cell. (Also see
.SM
.B "BUGS "
below.)
-
+.
.TP
-.PD 0
-.BR \-b
-.TP
-.PD
+.B \-b
+.TQ
.B \-\-border-mode
Border mode: force single column.
-
+.
.TP
-.PD 0
.BR \-c " <\fIcols\fR>"
-.TP
-.PD
+.TQ
.BR \-\-columns= <\fIcols\fR>
Set maximum table width in columns (default 80).
-
+.
.TP
-.PD 0
.BR \-d " <\fIdelim\fR>"
-.TP
-.PD
+.TQ
.BR \-\-delimiter= <\fIdelim\fR>
Set field delimiter (default ","). First line of the input determines the number
of table columns. Special characters, like ";", need to be quoted:
-.ft CB
+.EX
.in +4
$ table -d ';'
.in -4
-.ft R
-
+.EE
+.
.TP
-.PD 0
.BR \-h
-.TP
-.PD
+.TQ
.B \-\-help
.br
Print this usage information screen.
-
+.
.TP
-.PD 0
.BR \-s " <\fIset\fR>"
-.TP
-.PD
+.TQ
.BR \-\-symbols= <\fIset\fR>
+.br
Use table symbol set <set> for table lines,
where <\fIset\fR> is one of the following
(format: <\fIborder\fR><\fIinner border\fR>):
-.in +4
- \fIaa\fR = ascii-ascii,
- \fIss\fR = single-single,
- \fIsd\fR = single-double,
- \fIds\fR = double-single (default),
- \fIdd\fR = double-double.
-.in -4
-
+.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
-.PD 0
.B \-v
-.TP
-.PD
+.TQ
.B \-\-version
+.br
Print program version and exit.
-
+.
.SH "SEE ALSO"
.BR awk (1),
.BR sed (1)
+.
.SH EXAMPLES
+.
.TP
-.ft CB
+.EX
$ watch "table /proc/loadavg -d ' ' -c 50 -s ss"
-.ft R
+.EE
Periodically display
.SM CPU
load information in a single-line table
-
-
+.
.TP
-.ft CB
+.EX
$ ls -l | tail -n +2 | sed -e 's/ \+/ /g' | table -d ' '
-.ft R
+.EE
Format a long list of files in the current directory in a double line table with
single-line column divisors
-
-
+.
.TP
-.ft CB
+.EX
$ ls -l | tail -n +2 | awk '{ print $1 " " $9 }' | table -d ' ' -c 30
-.ft R
+.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
@@ -138,15 +140,14 @@ sequences are not handled as well as they should as of
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:
-.BS
-.in +4
-.B https://github.com/Strahinja/table/issues
-.in -4
-.BE
+.UR https://\:github.com/\:Strahinja/\:table/\:issues
+.UE