Re-order --help messages.

Divided them into 3 categories:
  - general
  - search
  - output

Closes: #12
This commit is contained in:
tastytea 2021-06-24 18:33:16 +02:00
parent 961deff41d
commit 979dc9334c
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
2 changed files with 44 additions and 28 deletions

View File

@ -52,6 +52,9 @@ Display a short help message and exit.
*V*, *--version*::
Show version, copyright and license.
*--debug*::
Write debug output to the terminal and log file.
*-G*, *--basic-regexp*::
_PATTERN_ is a POSIX basic regular expression. This is the default.
@ -69,13 +72,22 @@ _PATTERN_ is a Perl regular expression.
*-i*, *--ignore-case*::
Ignore case distinctions in pattern and data.
*-e* _PATTERN_, *--regexp* _PATTERN_::
Use additional _PATTERN_ for matching. Can be used more than once.
*-a*, *--raw*::
Do not clean up text before searching. No HTML stripping, no newline removal,
all files will be read (not just the text documents listed in the spine).
*-r*, *--recursive*::
Read all files under each directory, recursively, following symbolic links only
if they are on the command line. Silently skips directories that are not
readable by the user.
*-R*, *--dereference-recursive*::
Read all files under each directory, recursively. Follow all symbolic
links. Silently skips directories that are not readable by the user.
*-e* _PATTERN_, *--regexp* _PATTERN_::
Use additional _PATTERN_ for matching. Can be used more than once.
*-C* _NUMBER_, *context* _NUMBER_::
Print _NUMBER_ words of context around matches.
@ -88,23 +100,11 @@ Suppress the mentioning of file names on output. _WHICH_ is filesystem for
file names on your file systems, in-epub for the file names inside the EPUB or
all. Chapters and page numbers will still be output.
*-r*, *--recursive*::
Read all files under each directory, recursively, following symbolic links only
if they are on the command line. Silently skips directories that are not
readable by the user.
*-R*, *--dereference-recursive*::
Read all files under each directory, recursively. Follow all symbolic
links. Silently skips directories that are not readable by the user.
*--ignore-archive-errors*::
Ignore errors about wrong file formats. When you search directories recursively,
it is likely that there are files which are not EPUB files. This setting
suppresses errors related to them.
*--debug*::
Write debug output to the terminal and log file.
*--json*::
Output JSON instead of plain text. JSON will only be output at the end of the
program. There will be an object named `generator` with the property
@ -116,7 +116,8 @@ Output HTML instead of plain text. HTML will only be output at the end of the
program.
*--status*::
Output status message every *--status-interval* seconds to standard error.
Output status message every *--status-interval* seconds to standard
error. Default is 30.
*--status-interval* _NUMBER_::
Set status message interval to _NUMBER_ seconds.

View File

@ -49,13 +49,19 @@ using std::cout;
options parse_options(int argc, char *argv[])
{
po::options_description options_visible(translate("Available options"));
// clang-format off
options_visible.add_options()
po::options_description options_general(translate("General options"));
options_general.add_options()
("help,h",
translate("Display this help and exit.").str().data())
("version,V",
translate("Display version information and exit.").str().data())
("debug",
translate("Enable debug output.").str().data())
;
po::options_description options_search(translate("Search options"));
options_search.add_options()
("basic-regexp,G",
translate("PATTERN is a basic regular expression (default).")
.str().data())
@ -66,14 +72,25 @@ options parse_options(int argc, char *argv[])
.str().data())
("perl-regexp,P",
translate("PATTERN is a Perl regular expression.").str().data())
("ignore-case,i",
translate("Ignore case distinctions in pattern and data.")
.str().data())
("raw,a",
translate("Do not clean up text before searching.").str().data())
("recursive,r",
translate("Read all files under each directory, recursively.")
.str().data())
("dereference-recursive,R",
translate("Read all files under each directory, recursively, "
"following symlinks.").str().data())
("regexp,e", po::value<std::vector<std::string>>()
->value_name(translate("PATTERN"))->composing()->required(),
translate("Use additional PATTERN for matching.").str().data())
("raw,a",
translate("Do not clean up text before searching.").str().data())
;
po::options_description options_output(translate("Output options"));
options_output.add_options()
("context,C", po::value<std::uint64_t>()
->value_name(translate("NUMBER"))->default_value(0),
translate("Print NUMBER words of context around matches.")
@ -83,16 +100,8 @@ options parse_options(int argc, char *argv[])
("no-filename",po::value<std::string>()->value_name(translate("WHICH")),
translate("Suppress the mentioning of file names on output. "
"WHICH is filesystem, in-epub or all.").str().data())
("recursive,r",
translate("Read all files under each directory, recursively.")
.str().data())
("dereference-recursive,R",
translate("Read all files under each directory, recursively, "
"following symlinks.").str().data())
("ignore-archive-errors",
translate("Ignore errors about wrong file formats.").str().data())
("debug",
translate("Enable debug output.").str().data())
("json",
translate("Output JSON instead of plain text.").str().data())
("html",
@ -112,6 +121,12 @@ options parse_options(int argc, char *argv[])
->value_name("FILE"), "Input file to search.")
;
// clang-format on
po::options_description options_visible;
options_visible.add(options_general)
.add(options_search)
.add(options_output);
po::options_description options_all("Allowed options");
options_all.add(options_visible).add(options_hidden);