Add --nocolor switch.

Closes: #2
This commit is contained in:
tastytea 2021-05-25 11:45:25 +02:00
parent 8d361f88d7
commit fd8db544bd
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
2 changed files with 14 additions and 5 deletions

View File

@ -125,10 +125,17 @@ int main(int argc, char *argv[])
{
cout << ", page " << match.page;
}
cout << ": " << match.context.first
<< termcolor::bright_magenta << match.text
<< termcolor::reset << match.context.second
<< '\n';
cout << ": " << match.context.first;
if (vm.count("nocolor") == 0)
{
cout << termcolor::bright_magenta << match.text
<< termcolor::reset;
}
else
{
cout << match.text;
}
cout << match.context.second << '\n';
}
}
catch (const std::exception &e)

View File

@ -70,7 +70,9 @@ po::variables_map parse_options(int argc, char *argv[])
translate("Do not clean up text before searching.").str().data())
("context,C", po::value<std::uint64_t>()
->value_name(translate("NUMBER"))->default_value(0),
translate("Print NUMBER words of context around matches.").str().data())
translate("Print NUMBER words of context around matches.")
.str().data())
("nocolor", translate("Do not color matches.") .str().data())
;
po::options_description options_hidden("Hidden options");