summaryrefslogtreecommitdiffstats
path: root/main.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2014-09-03 05:22:45 +0000
committerIngo Schwarze <schwarze@openbsd.org>2014-09-03 05:22:45 +0000
commit23314f00a3de516604e28d2a34bde0428f6067fb (patch)
tree41f72d0cdd36e6f74d193974466fff1871fa7967 /main.c
parent3d35e7c87bf69138c20259187b52c26c01ab6cda (diff)
downloadmandoc-23314f00a3de516604e28d2a34bde0428f6067fb.tar.gz
Implement the traditional -h option for man(1): show the SYNOPSIS only.
As usual, we get mandoc -h and apropos -h for free. Try stuff like "apropos -h In=dirent" or "apropos -h Fa=timespec". Only useful for terminal output, so -Tps, -Tpdf, -Thtml ignore -h for now.
Diffstat (limited to 'main.c')
-rw-r--r--main.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/main.c b/main.c
index 4c71266f..5c13d2f7 100644
--- a/main.c
+++ b/main.c
@@ -154,7 +154,7 @@ main(int argc, char *argv[])
show_usage = 0;
outmode = OUTMODE_DEF;
- while (-1 != (c = getopt(argc, argv, "aC:cfI:iklM:m:O:S:s:T:VW:w"))) {
+ while (-1 != (c = getopt(argc, argv, "aC:cfhI:iklM:m:O:S:s:T:VW:w"))) {
switch (c) {
case 'a':
outmode = OUTMODE_ALL;
@@ -168,6 +168,10 @@ main(int argc, char *argv[])
case 'f':
search.argmode = ARG_WORD;
break;
+ case 'h':
+ (void)strlcat(curp.outopts, "synopsis,", BUFSIZ);
+ outmode = OUTMODE_ALL;
+ break;
case 'I':
if (strncmp(optarg, "os=", 3)) {
fprintf(stderr,
@@ -414,7 +418,7 @@ usage(enum argmode argmode)
switch (argmode) {
case ARG_FILE:
- fputs("usage: mandoc [-acfklV] [-Ios=name] "
+ fputs("usage: mandoc [-acfhklV] [-Ios=name] "
"[-mformat] [-Ooption] [-Toutput] [-Wlevel]\n"
"\t [file ...]\n", stderr);
break;
@@ -424,12 +428,12 @@ usage(enum argmode argmode)
"\t [section] name ...\n", stderr);
break;
case ARG_WORD:
- fputs("usage: whatis [-acfklVw] [-C file] "
+ fputs("usage: whatis [-acfhklVw] [-C file] "
"[-M path] [-m path] [-O outkey] [-S arch]\n"
"\t [-s section] name ...\n", stderr);
break;
case ARG_EXPR:
- fputs("usage: apropos [-acfklVw] [-C file] "
+ fputs("usage: apropos [-acfhklVw] [-C file] "
"[-M path] [-m path] [-O outkey] [-S arch]\n"
"\t [-s section] expression ...\n", stderr);
break;