aboutsummaryrefslogtreecommitdiffstatshomepage
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
commit02046d75d7ec4c27ec31d04e15c9d9fe018a01ab (patch)
tree88fb456e129ed40338e63c83d92faea4da97a7b1 /main.c
parent62dcabc9f407fb96cb3f2517d3f6d5f39dd756b1 (diff)
downloadmandoc-02046d75d7ec4c27ec31d04e15c9d9fe018a01ab.tar.gz
mandoc-02046d75d7ec4c27ec31d04e15c9d9fe018a01ab.tar.zst
mandoc-02046d75d7ec4c27ec31d04e15c9d9fe018a01ab.zip
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.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/main.c b/main.c
index a6d5013b..81f2d0c9 100644
--- a/main.c
+++ b/main.c
@@ -1,4 +1,4 @@
-/* $Id: main.c,v 1.189 2014/09/01 22:45:53 schwarze Exp $ */
+/* $Id: main.c,v 1.190 2014/09/03 05:22:45 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2011, 2012, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -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;