author | Olivier Brunel
<jjk@jjacky.com> 2023-06-04 13:50:17 UTC |
committer | Olivier Brunel
<jjk@jjacky.com> 2023-07-07 16:59:36 UTC |
parent | ab1f8cccd9835e8ba5cbe5abf5e0551b4a43144f |
src/qmdoc/qmdoc.c | +23 | -10 |
diff --git a/src/qmdoc/qmdoc.c b/src/qmdoc/qmdoc.c index 937b652..b6530af 100644 --- a/src/qmdoc/qmdoc.c +++ b/src/qmdoc/qmdoc.c @@ -2,6 +2,7 @@ #include <stdlib.h> #include <unistd.h> #include <time.h> +#include <limb/autoopt.h> #include <limb/buffer.h> #include <limb/bytestr.h> #include <limb/direntry.h> @@ -1849,6 +1850,7 @@ enum { OPTID_SORT_GROUP, OPTID_DIR, OPTID_SUBDIR, + OPTID_VERBOSE, ARGID_FILE }; @@ -1870,12 +1872,14 @@ parse_cmdline(int argc, const char *argv[], const char usage[], struct parse *ct OPTION_ARG_REQ( 'l', "lang", 0, OPTID_SHORTOPT), OPTION_ARG_REQ( 'M', "man-url", OPT_PATH, OPTID_SHORTOPT), OPTION_ARG_NONE('o', "overwrite", 0, OPTID_SHORTOPT), + AUTOOPT_QUIET( 'q', "quiet", 0, OPTID_SHORTOPT), OPTION_ARG_REQ( 's', "subtitle", OPT_PATH, OPTID_SHORTOPT), OPTION_ARG_REQ( 0 , "subdir", 0, OPTID_SUBDIR), OPTION_ARG_REQ( 0 , "sharedir", OPT_PATH, OPTID_SHAREDIR), OPTION_ARG_REQ( 0 , "sort-group", 0, OPTID_SORT_GROUP), OPTION_ARG_NONE('T', "no-toc", 0, OPTID_SHORTOPT), OPTION_ARG_REQ( 't', "title", OPT_PATH, OPTID_SHORTOPT), + AUTOOPT_VERBOSE( 0 , "verbose", 0, OPTID_VERBOSE), OPTION_ARG_NONE( 0 , "version", 0, OPTID_VERSION), OPTION_ARG_NONE('W', "wide-includes", 0, OPTID_SHORTOPT), OPTION_ARG_NONE('X', "no-index", 0, OPTID_SHORTOPT), @@ -1943,13 +1947,15 @@ parse_cmdline(int argc, const char *argv[], const char usage[], struct parse *ct " -l, --lang LNG Set LNG as language attribute [en]\n" " -M, --man-url URL Use URL as prefix for external man-page links\n" " -o, --overwrite Overwrite destination files if already exist\n" +" -q, --quiet Reduce output verbosity\n" " -s, --subtitle TEXT Set TEXT as general subtitle\n" " --subdir TYPE Starting a new TYPE when reading sub-directories [group]\n" " --sharedir DIR Use DIR as source for qmdoc's CSS files [" QMDOC_SHAREDIR "]\n" " --sort-group SORT Use SORT as sort order for sorting groups [title]\n" " -T, --no-toc Don't write a TOC on each page. Implies --no-index\n" " -t, --title TITLE Set TITLE as general (across all pages) title [Documentation]\n" -" -V, --version Show version screen and exit\n" +" --verbose Increase output verbosity\n" +" --version Show version screen and exit\n" " -W, --wide-include Include header/footer right within <body>\n" " -X, --no-index Disable index mode\n" ); @@ -1968,6 +1974,9 @@ parse_cmdline(int argc, const char *argv[], const char usage[], struct parse *ct case 'o': ctx->qmdoc->options |= OPT_OVERWRITE; break; + case 'q': + autoopt_quiet(&options[LO_IDX(&lo)], LO_ARG(&lo)); + break; case 's': ctx->qmdoc->doc.osubtitle = LO_OFF(&lo); break; @@ -1985,15 +1994,18 @@ parse_cmdline(int argc, const char *argv[], const char usage[], struct parse *ct case 't': ctx->qmdoc->doc.otitle = LO_OFF(&lo); break; + case OPTID_VERBOSE: + autoopt_verbose(&options[LO_IDX(&lo)], LO_ARG(&lo)); + break; + case OPTID_VERSION: + dieversion(QMDOC_VERSION, "2023", QMDOC_CURYEAR, QMDOC_AUTHOR, QMDOC_URL, NULL); + break; case 'W': ctx->qmdoc->options |= OPT_WIDE_INC; break; case 'X': ctx->qmdoc->options |= OPT_NO_INDEX; break; - case OPTID_VERSION: - dieversion(QMDOC_VERSION, "2023", QMDOC_CURYEAR, QMDOC_AUTHOR, QMDOC_URL, NULL); - break; case ARGID_FILE: if (nfile++ == 0) @@ -2106,7 +2118,7 @@ main (int argc, const char *argv[]) genalloc ga_sg = GENALLOC_ZERO; - out("Scanning pages..."); + quiet("Scanning pages..."); r = scan_pages(&idx_mode, AT_FDCWD, &ctx.sa, parse.ffile, nb_pages, 1, &ga_sg, &parse); if (r) diefu(r, "prepage pages"); @@ -2185,7 +2197,7 @@ main (int argc, const char *argv[]) if (NB_PAGES(&ctx) == 0) dief(EX_NOINPUT, "nothing to do"); if (parse.header != (size_t) -1 || parse.footer != (size_t) -1) { - out("Loading files..."); + quiet("Loading files..."); if (parse.header != (size_t) -1) { ctx.doc.oheader = ctx.sa.len; @@ -2202,7 +2214,7 @@ main (int argc, const char *argv[]) } if (!(ctx.options & OPT_NO_CSS) || ctx.css[CSS_CUSTOM] != (size_t) -1) { - out((ctx.options & OPT_INLINE_CSS) ? "Loading" : "Copying", " CSS files..."); + quiet((ctx.options & OPT_INLINE_CSS) ? "Loading" : "Copying", " CSS files..."); int dirfd; if (!(ctx.options & OPT_NO_CSS)) { dirfd = open2((parse.sharedir == (size_t) -1) ? QMDOC_SHAREDIR @@ -2310,10 +2322,11 @@ main (int argc, const char *argv[]) break; } - add(PMUINT(NB_PAGES(&ctx) - !(ctx.doc.flags & DOC_FULL_TOC)), " files written"); + outmsg(OLVL_QUIET, PMUINT(NB_PAGES(&ctx)), + PMLEN(" files", (NB_PAGES(&ctx) > 1) ? 6 : 5), " written"); r = NB_ENTRIES(&ctx) - NB_PAGES(&ctx) - !(ctx.doc.flags & DOC_FULL_TOC); - if (r) add(" (", PMUINT(r), " links processed)"); - out("."); + if (r) outmsg(OLVL_QUIET, " (", PMUINT(r), " links processed)"); + quiet("."); stralloc_free(&ctx.buf.sa); stralloc_free(&ctx.sa_out);