commit b101976ee05375f91883d127fa93ddd84ad4f30e
parent 9203ee6788b8c9927dbf21db9b8036580676aad6
Author: Jacob R. Edwards <jacobouno@protonmail.com>
Date: Mon, 21 Dec 2020 01:21:51 -0800
Add a manual and update command documentation
Diffstat:
M | Makefile | | | 4 | ---- |
A | gawk.1 | | | 54 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
M | main.c | | | 21 | ++++++++++----------- |
3 files changed, 64 insertions(+), 15 deletions(-)
diff --git a/Makefile b/Makefile
@@ -24,12 +24,8 @@ clean:
install: ${TARGET}
mv -f ${TARGET} ${PREFIX}/bin/${TARGET}
-.ifdef MANPREFIX
cp -f ${TARGET}.1 ${MANPREFIX}/man1/${TARGET}.1
-.endif
uninstall:
rm -f ${PREFIX}/bin/${TARGET}
-.ifdef MANPREFIX
rm -f ${MANPREFIX}/man1/${TARGET}.1
-.endif
diff --git a/gawk.1 b/gawk.1
@@ -0,0 +1,54 @@
+.TH GAWK 1 2020.12.21
+.SH NAME
+gawk \(em gawk at gopher holes
+.SH SYNOPSIS
+.B gawk
+.OP path
+|
+.OP host
+.OP path
+.OP port
+.SH DESCRIPTION
+gawk is a simple gopher client which utilizes the standard input
+to allow for both interactive and non-interactive usage.
+.SH USAGE
+.SS Commands
+.TP
+.RB [ U | q ]
+.TQ
+Unwind the whole stack
+.TP
+.B p
+.OP type
+.OP substring
+.TQ
+Print gopher-text
+.TP
+.RB [ s | g ]
+.OP path
+|
+.OP host
+.OP path
+.OP port
+.TQ
+Goto new location
+.TP
+.RB [ u | b ]
+.OP n
+.TQ
+Unwind the stack.
+.TP
+.RB [ w | f ]
+.OP item
+.OP file
+.TQ
+Write to file.
+.SS Command syntax
+Commands are separated by linefeeds semicolens (`;') and the first
+non-space character is taken as the command to invoke and each token
+separated by colen (`:'), <tab>, and <space> following it is passed
+as an argument.
+.SH AUTHOR
+Jacob R. Edwards
+.SH SEE ALSO
+.BR gophmt (1)
diff --git a/main.c b/main.c
@@ -339,10 +339,9 @@ exfmt(int (*putter)(const char *, int, const char **), const char *path, int arg
return 0;
}
-/* if lacking arguments goes to the root (`/') keeping the host and
- * port. If one argument is given it is taken as a path, if more
- * than one is given argv[0] is the host, argv[1] is the path, and
- * if present argv[2] is the port.
+/* If lacking arguments goes to root (`/'). If one argument is given
+ * it is taken as a path, if multiple are given the first is the host,
+ * the second the path, and the optional third the port.
*/
int
cgoto(int argc, const char **argv, int depth, const char *tmpdir, const char *host,
@@ -501,19 +500,19 @@ execute(int command, int argc, const char **argv, int depth, const char *cache,
const char *tmpdir, const char *host, const char *path, const char *port)
{
switch (command) {
- case 'q':
+ case 'U': case 'q': /* unwind the whole stack */
wunused(0, argc, argv);
return depth;
- case 'p':
+ case 'p': /* print gopher-text */
exfmt(cmatch, cache, argc, argv);
return 0;
- case 'f':
+ case 's': case 'g': /* goto new location */
+ return cgoto(argc, argv, depth, tmpdir, host, path, port);
+ case 'u': case 'b': /* unwind [n] */
+ return cback(argc, argv);
+ case 'w': case 'f': /* write to file */
cfetch(argc, argv, cache, host, port);
return 0;
- case 'b':
- return cback(argc, argv);
- case 'g':
- return cgoto(argc, argv, depth, tmpdir, host, path, port);
default:
warnx("invalid command '%c'", command);
return 0;