From 02046d75d7ec4c27ec31d04e15c9d9fe018a01ab Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Wed, 3 Sep 2014 05:22:45 +0000 Subject: 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. --- main.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'main.c') 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 * Copyright (c) 2010, 2011, 2012, 2014 Ingo Schwarze @@ -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; -- cgit v1.2.3