From c34aeba5a43620e50afd6d710dad9a70397caa3b Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Tue, 16 Feb 2010 00:16:51 -0500 Subject: [PATCH] Enhancement - config error highlights - Configuration variables that are unrecognized are now highlighted in color, as well as being listed out. --- ChangeLog | 6 ++-- src/command.cpp | 82 +++++++++++++++++++++++++++---------------------- 2 files changed, 50 insertions(+), 38 deletions(-) diff --git a/ChangeLog b/ChangeLog index 32d2644c9..5b3d73a9f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ ------ current release --------------------------- +2.0.0 () + + The 'config' command now highlights problems in color. + +------ old releases ------------------------------ 1.9.0 () + Added feature #283 that makes it possible to control the verbosity @@ -103,8 +107,6 @@ + Fixed bug #372 which incorrectly mapped 16-color backgrounds into the 256-color space. ------- old releases ------------------------------ - 1.8.5 (12/05/2009) a6c7236ff34e5eee3ef1693b97cb1367e6e3c607 + Added feature to allow the user to quit when asked to confirm multiple changes. Now task asks "Proceed with change? (Yes/no/all/quit)". diff --git a/src/command.cpp b/src/command.cpp index 76a5d3a66..0f2a0c5ff 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -664,41 +664,6 @@ int handleConfig (std::string &outs) std::vector all; context.config.all (all); - // Create a table for output. - Table table; - table.setTableWidth (width); - table.setDateFormat (context.config.get ("dateformat")); - table.addColumn ("Config variable"); - table.addColumn ("Value"); - - if (context.config.getBoolean ("color") || context.config.getBoolean ("_forcecolor")) - { - table.setColumnUnderline (0); - table.setColumnUnderline (1); - } - else - table.setTableDashedUnderline (); - - table.setColumnWidth (0, Table::minimum); - table.setColumnWidth (1, Table::flexible); - table.setColumnJustification (0, Table::left); - table.setColumnJustification (1, Table::left); - table.sortOn (0, Table::ascendingCharacter); - - foreach (i, all) - { - std::string value = context.config.get (*i); - int row = table.addRow (); - table.addCell (row, 0, *i); - table.addCell (row, 1, value); - } - - Color bold ("bold"); - - out << std::endl - << table.render () - << std::endl; - // Complain about configuration variables that are not recognized. // These are the regular configuration variables. // Note that there is a leading and trailing space, to make searching easier. @@ -753,14 +718,59 @@ int handleConfig (std::string &outs) } } + // Create a table for output. + Table table; + table.setTableWidth (width); + table.setDateFormat (context.config.get ("dateformat")); + table.addColumn ("Config variable"); + table.addColumn ("Value"); + + if (context.config.getBoolean ("color") || context.config.getBoolean ("_forcecolor")) + { + table.setColumnUnderline (0); + table.setColumnUnderline (1); + } + else + table.setTableDashedUnderline (); + + table.setColumnWidth (0, Table::minimum); + table.setColumnWidth (1, Table::flexible); + table.setColumnJustification (0, Table::left); + table.setColumnJustification (1, Table::left); + table.sortOn (0, Table::ascendingCharacter); + + Color error ("bold white on red"); + foreach (i, all) + { + std::string value = context.config.get (*i); + int row = table.addRow (); + table.addCell (row, 0, *i); + table.addCell (row, 1, value); + + if (context.config.getBoolean ("color") || context.config.getBoolean ("_forcecolor")) + if (std::find (unrecognized.begin (), unrecognized.end (), *i) != unrecognized.end ()) + table.setRowColor (row, error); + } + + Color bold ("bold"); + + out << std::endl + << table.render () + << std::endl; + + // Display the unrecognized variables. if (unrecognized.size ()) { out << "Your .taskrc file contains these unrecognized variables:" - << std::endl; + << std::endl; foreach (i, unrecognized) out << " " << *i << std::endl; + if (context.config.getBoolean ("color") || context.config.getBoolean ("_forcecolor")) + out << std::endl + << " These are highlighted in " << error.colorize ("color") << " above."; + out << std::endl; }