- Created legacy checking function to determine whether deprecated or obsolete
  attributes are being used.
This commit is contained in:
Paul Beckingham 2011-09-12 22:45:58 -04:00
parent fa22b98dc4
commit 02047a6e99
3 changed files with 62 additions and 42 deletions

View file

@ -36,6 +36,7 @@
#include <i18n.h>
#include <Command.h>
#include <cmake.h>
#include <main.h>
#include <CmdAdd.h>
#include <CmdAnnotate.h>
@ -431,14 +432,20 @@ void Command::modify_task (
Column* column = context.columns[name];
// All values must be eval'd first.
A3 fragment;
fragment.capture (value);
fragment = fragment.postfix (fragment.tokenize (fragment));
A3 value_tokens;
value_tokens.capture (value);
value_tokens = value_tokens.postfix (value_tokens.tokenize (value_tokens));
E9 e (fragment);
E9 e (value_tokens);
std::string result = e.evalExpression (task);
context.debug (std::string ("Eval '") + value + "' --> '" + result + "'");
if (result == "")
{
task.remove (name);
}
else
{
// Dependencies must be resolved to UUIDs.
if (name == "depends")
{
@ -474,13 +481,13 @@ void Command::modify_task (
task.set (name, result);
}
// By default, just add it.
// By default, just add/remove it.
else
task.set (name, result);
// Legacy checks.
if (name == "fg" || name == "bg")
context.footnote (format (STRING_LEGACY_FEATURE, name));
// Warn about deprecated/obsolete attribute usage.
legacyAttributeCheck (name);
}
}
else
throw format (STRING_CMD_ADD_BAD_ATTRIBUTE, name);

View file

@ -25,11 +25,21 @@
//
////////////////////////////////////////////////////////////////////////////////
#define L10N // Localization complete.
#include <Context.h>
#include <text.h>
#include <i18n.h>
extern Context context;
////////////////////////////////////////////////////////////////////////////////
void legacyAttributeCheck (const std::string& name)
{
// Legacy checks.
if (name == "fg" || name == "bg")
context.footnote (format (STRING_LEGACY_FEATURE, name));
}
////////////////////////////////////////////////////////////////////////////////

View file

@ -78,6 +78,9 @@ std::string feedback (const Task&, const Task&);
// sort.cpp
void sort_tasks (std::vector <Task>&, std::vector <int>&, const std::string&);
// legacy.cpp
void legacyAttributeCheck (const std::string&);
// list template
///////////////////////////////////////////////////////////////////////////////
template <class T> bool listDiff (const T& left, const T& right)