Show Command Defaults

- Added highlighting for the show command that indicates which values differ
  from the defaults.
This commit is contained in:
Paul Beckingham 2010-11-26 19:32:37 -05:00
parent 7a95c38290
commit fe85e28605
3 changed files with 28 additions and 1 deletions

View file

@ -5,6 +5,8 @@
+ Added burndown charts - burndown.daily, burndown.weekly, burndown.monthly,
that use color.burndown.pending, color.burndown.started and
color.burndown.done colors.
+ Added highlighting for the show command that indicates which values differ
from the defaults.
+ Added feature #158, regular expression support for filters and substitutions.
+ Added feature #247, providing infinite width reports when redirecting output
to a file, by setting defaultwidth to 0.

2
NEWS
View file

@ -5,6 +5,8 @@ New Features in taskwarrior 1.9.4
- New 'count' helper command.
- Inifinite width reports, when redirecting output.
- Regular expression support in filters and substitutions.
- Added highlighting for the show command that indicates which values differ
from the defaults.
Please refer to the ChangeLog file for full details. There are too many to
list here.

View file

@ -958,6 +958,15 @@ int handleShow (std::string& outs)
}
}
// Find all the values that match the defaults, for highlighting.
std::vector <std::string> default_values;
Config default_config;
default_config.setDefaults ();
foreach (i, all)
if (context.config.get (*i) != default_config.get (*i))
default_values.push_back (*i);
// Create a table for output.
Table table;
table.setTableWidth (width);
@ -980,6 +989,7 @@ int handleShow (std::string& outs)
table.sortOn (0, Table::ascendingCharacter);
Color error ("bold white on red");
Color warning ("black on yellow");
std::string section;
@ -1001,8 +1011,13 @@ int handleShow (std::string& outs)
// Look for unrecognized.
if (context.config.getBoolean ("color") || context.config.getBoolean ("_forcecolor"))
{
if (std::find (unrecognized.begin (), unrecognized.end (), *i) != unrecognized.end ())
table.setRowColor (row, error);
else if (std::find (default_values.begin (), default_values.end (), *i) != default_values.end ())
table.setRowColor (row, warning);
}
}
}
@ -1021,7 +1036,15 @@ int handleShow (std::string& outs)
if (context.config.getBoolean ("color") || context.config.getBoolean ("_forcecolor"))
out << "\n These are highlighted in " << error.colorize ("color") << " above.";
out << "\n";
out << "\n\n";
}
if (default_values.size ())
{
out << "Some of your .taskrc variables differ from the default values.";
if (context.config.getBoolean ("color") || context.config.getBoolean ("_forcecolor"))
out << " These are highlighted in " << warning.colorize ("color") << " above.";
}
out << context.config.checkForDeprecatedColor ();