Add setting to suppress this-is-not-an-EPUB errors.
This commit is contained in:
parent
84f600196c
commit
c3131e01f0
@ -73,6 +73,11 @@ readable by the user.
|
|||||||
Read all files under each directory, recursively. Follow all symbolic
|
Read all files under each directory, recursively. Follow all symbolic
|
||||||
links. Silently skips directories that are not readable by the user.
|
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.
|
||||||
|
|
||||||
== USAGE
|
== USAGE
|
||||||
|
|
||||||
[source,shellsession]
|
[source,shellsession]
|
||||||
@ -104,12 +109,14 @@ occur more than once are merged.
|
|||||||
|
|
||||||
==== Example configuration file
|
==== Example configuration file
|
||||||
|
|
||||||
This example makes epubgrep always suppress the file names on output, print 2
|
This example makes epubgrep ignore files which are not EPUB, suppress the file
|
||||||
words of context around matches (unless overridden on the command line) and
|
names on output, print 2 words of context around matches (unless overridden on
|
||||||
search for mentions of the words thyme and oregano in every book.
|
the command line) and search for mentions of the words thyme and oregano in
|
||||||
|
every book.
|
||||||
|
|
||||||
[source,cfg]
|
[source,cfg]
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
ignore-archive-errors
|
||||||
no-filename
|
no-filename
|
||||||
context = 2
|
context = 2
|
||||||
regexp = [Tt]hyme
|
regexp = [Tt]hyme
|
||||||
|
@ -148,6 +148,11 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
catch (const zip::exception &e)
|
catch (const zip::exception &e)
|
||||||
{
|
{
|
||||||
|
if (opts.ignore_archive_errors && e.code == 1)
|
||||||
|
{
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
cerr << translate("ERROR: ") << e.what() << '\n';
|
cerr << translate("ERROR: ") << e.what() << '\n';
|
||||||
cerr << format(translate("Error while searching {0:s}.")
|
cerr << format(translate("Error while searching {0:s}.")
|
||||||
.str(),
|
.str(),
|
||||||
|
@ -84,6 +84,8 @@ options parse_options(int argc, char *argv[])
|
|||||||
("dereference-recursive,R",
|
("dereference-recursive,R",
|
||||||
translate("Read all files under each directory, recursively, "
|
translate("Read all files under each directory, recursively, "
|
||||||
"following symlinks.") .str().data())
|
"following symlinks.") .str().data())
|
||||||
|
("ignore-archive-errors",
|
||||||
|
translate("Ignore errors about wrong file formats.") .str().data())
|
||||||
;
|
;
|
||||||
|
|
||||||
po::options_description options_hidden("Hidden options");
|
po::options_description options_hidden("Hidden options");
|
||||||
@ -223,6 +225,7 @@ options parse_again(const po::variables_map &vm)
|
|||||||
}
|
}
|
||||||
opts.recursive = vm.count("recursive") > 0;
|
opts.recursive = vm.count("recursive") > 0;
|
||||||
opts.dereference_recursive = vm.count("dereference-recursive") > 0;
|
opts.dereference_recursive = vm.count("dereference-recursive") > 0;
|
||||||
|
opts.ignore_archive_errors = vm.count("ignore-archive-errors") > 0;
|
||||||
|
|
||||||
if (vm.count("regexp") > 0)
|
if (vm.count("regexp") > 0)
|
||||||
{
|
{
|
||||||
|
@ -54,6 +54,7 @@ struct options
|
|||||||
bool recursive{false};
|
bool recursive{false};
|
||||||
bool dereference_recursive{false};
|
bool dereference_recursive{false};
|
||||||
std::vector<std::string> input_file;
|
std::vector<std::string> input_file;
|
||||||
|
bool ignore_archive_errors{false};
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Parse options and return them.
|
//! Parse options and return them.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user