CmdHelp: Added :color/:nocolor hints

This commit is contained in:
Paul Beckingham 2016-04-10 12:40:50 -04:00
parent d0ec6fc4a8
commit 4ecc1e4f40
2 changed files with 13 additions and 4 deletions

View file

@ -216,6 +216,9 @@ int CmdHelp (const CLI& cli)
<< " :quiet Turns off all feedback. For automation\n"
<< " :debug Runs in debug mode, shows many runtime details\n"
<< "\n"
<< " :color Force color on, even if not connected to a TTY\n"
<< " :nocolor Force color off, even if connected to a TTY\n"
<< "\n"
<< " :day The 24-hours of the current day\n"
<< " :week This week\n"
<< " :month This month\n"

View file

@ -80,6 +80,8 @@ void initializeEntities (CLI& cli)
cli.entity ("hint", ":quarter");
cli.entity ("hint", ":year");
cli.entity ("hint", ":fill");
cli.entity ("hint", ":color");
cli.entity ("hint", ":nocolor");
}
////////////////////////////////////////////////////////////////////////////////
@ -89,14 +91,18 @@ void initializeDataAndRules (
Rules& rules)
{
// Make common hints available via rules:
// :debug --> debug
// :quiet --> verbose
// :debug --> debug=on
// :quiet --> verbose=off
// :color --> color=on
// :nocolor --> color=off
for (auto& arg : cli._args)
{
if (arg.hasTag ("HINT"))
{
if (arg.attribute ("canonical") == ":debug") rules.set ("debug", "on");
if (arg.attribute ("canonical") == ":quiet") rules.set ("verbose", "off");
if (arg.attribute ("canonical") == ":color") rules.set ("color", "on");
if (arg.attribute ("canonical") == ":nocolor") rules.set ("color", "coff");
}
}