mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Expressions
- Eliminated the . prefix for DOM references to the current task - it is unnatural to state ".due < today". - Prioritized parsing dates ahead of integers, which were masking all dates.
This commit is contained in:
parent
e564827be7
commit
09d94a0712
7 changed files with 27 additions and 25 deletions
|
@ -1551,7 +1551,7 @@ Arguments Arguments::extract_write_filter ()
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
Arguments Arguments::extract_modifications ()
|
Arguments Arguments::extract_modifications (bool include_seq/* = false*/)
|
||||||
{
|
{
|
||||||
Arguments modifications;
|
Arguments modifications;
|
||||||
|
|
||||||
|
@ -1569,6 +1569,8 @@ Arguments Arguments::extract_modifications ()
|
||||||
else if (arg->_third == "id" ||
|
else if (arg->_third == "id" ||
|
||||||
arg->_third == "uuid")
|
arg->_third == "uuid")
|
||||||
{
|
{
|
||||||
|
if (include_seq)
|
||||||
|
modifications.push_back (Triple (arg->_first, arg->_second, "word"));
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (seen_command)
|
else if (seen_command)
|
||||||
|
|
|
@ -131,7 +131,7 @@ public:
|
||||||
|
|
||||||
Arguments extract_read_only_filter ();
|
Arguments extract_read_only_filter ();
|
||||||
Arguments extract_write_filter ();
|
Arguments extract_write_filter ();
|
||||||
Arguments extract_modifications ();
|
Arguments extract_modifications (bool include_seq = false);
|
||||||
Arguments extract_simple_words ();
|
Arguments extract_simple_words ();
|
||||||
|
|
||||||
static bool valid_modifier (const std::string&);
|
static bool valid_modifier (const std::string&);
|
||||||
|
|
|
@ -255,9 +255,9 @@ const std::string DOM::get (const std::string& name, const Task& task)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// [<task>] .<name>
|
// [<task>.]<name>
|
||||||
if (name == ".id") return format (task.id);
|
if (name == "id") return format (task.id);
|
||||||
else if (name == ".urgency") return format (task.urgency_c (), 4, 3);
|
else if (name == "urgency") return format (task.urgency_c (), 4, 3);
|
||||||
else if (task.has (name.substr (1))) return task.get (name.substr (1));
|
else if (task.has (name.substr (1))) return task.get (name.substr (1));
|
||||||
|
|
||||||
// Delegate to the context-free version of DOM::get.
|
// Delegate to the context-free version of DOM::get.
|
||||||
|
|
|
@ -638,15 +638,15 @@ void Expression::tokenize (
|
||||||
else if (n.getNumber (d))
|
else if (n.getNumber (d))
|
||||||
tokens.push_back (Triple (format (d), "number", category));
|
tokens.push_back (Triple (format (d), "number", category));
|
||||||
|
|
||||||
else if (n.getInt (i))
|
|
||||||
tokens.push_back (Triple (format (i), "int", category));
|
|
||||||
|
|
||||||
else if (n.getDateISO (t))
|
else if (n.getDateISO (t))
|
||||||
tokens.push_back (Triple (Date (t).toISO (), "date", category));
|
tokens.push_back (Triple (Date (t).toISO (), "date", category));
|
||||||
|
|
||||||
else if (n.getDate (date_format, t))
|
else if (n.getDate (date_format, t))
|
||||||
tokens.push_back (Triple (Date (t).toString (date_format), "date", category));
|
tokens.push_back (Triple (Date (t).toString (date_format), "date", category));
|
||||||
|
|
||||||
|
else if (n.getInt (i))
|
||||||
|
tokens.push_back (Triple (format (i), "int", category));
|
||||||
|
|
||||||
else if (n.getWord (s))
|
else if (n.getWord (s))
|
||||||
tokens.push_back (Triple (s, "rvalue", category));
|
tokens.push_back (Triple (s, "rvalue", category));
|
||||||
|
|
||||||
|
|
|
@ -933,18 +933,6 @@ bool Nibbler::getDOM (std::string& result)
|
||||||
std::string right;
|
std::string right;
|
||||||
int number;
|
int number;
|
||||||
|
|
||||||
if (skip ('.') &&
|
|
||||||
getWord (right))
|
|
||||||
{
|
|
||||||
while (skip ('.') &&
|
|
||||||
getWord (right))
|
|
||||||
;
|
|
||||||
|
|
||||||
result = mInput.substr (i, mCursor - i);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
restore ();
|
|
||||||
if (getWord (left) &&
|
if (getWord (left) &&
|
||||||
skip ('.') &&
|
skip ('.') &&
|
||||||
getWord (right))
|
getWord (right))
|
||||||
|
@ -982,6 +970,18 @@ bool Nibbler::getDOM (std::string& result)
|
||||||
result = mInput.substr (i, mCursor - i);
|
result = mInput.substr (i, mCursor - i);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
restore ();
|
||||||
|
if (getWord (right))
|
||||||
|
{
|
||||||
|
while (skip ('.') &&
|
||||||
|
getWord (right))
|
||||||
|
;
|
||||||
|
|
||||||
|
result = mInput.substr (i, mCursor - i);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -56,7 +56,7 @@ int CmdAdd::execute (std::string& output)
|
||||||
task.set ("uuid", uuid ());
|
task.set ("uuid", uuid ());
|
||||||
|
|
||||||
// Apply the command line modifications to the new task.
|
// Apply the command line modifications to the new task.
|
||||||
Arguments modifications = context.args.extract_modifications ();
|
Arguments modifications = context.args.extract_modifications (true);
|
||||||
modify_task_description_replace (task, modifications);
|
modify_task_description_replace (task, modifications);
|
||||||
apply_defaults (task);
|
apply_defaults (task);
|
||||||
|
|
||||||
|
|
|
@ -414,9 +414,9 @@ int main (int argc, char** argv)
|
||||||
t.diag ("Nibbler::getDOM");
|
t.diag ("Nibbler::getDOM");
|
||||||
|
|
||||||
// positive.
|
// positive.
|
||||||
n = Nibbler (".due ");
|
n = Nibbler ("due ");
|
||||||
t.ok (n.getDOM (s), "'.due' getDOM -> ok");
|
t.ok (n.getDOM (s), "'due' getDOM -> ok");
|
||||||
t.is (s, ".due", "'.due' getDOM -> '.due'");
|
t.is (s, "due", "'due' getDOM -> 'due'");
|
||||||
|
|
||||||
n = Nibbler ("123.due ");
|
n = Nibbler ("123.due ");
|
||||||
t.ok (n.getDOM (s), "'123.due' getDOM -> ok");
|
t.ok (n.getDOM (s), "'123.due' getDOM -> ok");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue