mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Minor Refactoring
- Added support for more type-specific checks of attribute values. - Added support for more type-specific attribute rendering. - Improved generalized methods for checking columns in a report. - Added unit tests. - Minor code cleanup. - Added secret hidden feature for internal testing.
This commit is contained in:
parent
cffc42484e
commit
96fe3f42ba
83 changed files with 351 additions and 81 deletions
|
@ -25,7 +25,6 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#define L10N // Localization complete.
|
||||
|
||||
#include <sstream>
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#define L10N // Localization complete.
|
||||
|
||||
#include <sstream>
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#define L10N // Localization complete.
|
||||
|
||||
#include <sstream>
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#define L10N // Localization complete.
|
||||
|
||||
#include <algorithm>
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#define L10N // Localization complete.
|
||||
|
||||
#include <sstream>
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#define L10N // Localization complete.
|
||||
|
||||
#include <sstream>
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#define L10N // Localization complete.
|
||||
|
||||
#include <Context.h>
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#define L10N // Localization complete.
|
||||
|
||||
#include <sstream>
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#define L10N // Localization complete.
|
||||
|
||||
#include <iomanip>
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#define L10N // Localization complete.
|
||||
|
||||
#include <stdlib.h>
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#define L10N // Localization complete.
|
||||
|
||||
#include <Context.h>
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#define L10N // Localization complete.
|
||||
|
||||
#include <algorithm>
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#define L10N // Localization complete.
|
||||
|
||||
#include <sstream>
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#define L10N // Localization complete.
|
||||
|
||||
#include <iostream>
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#define L10N // Localization complete.
|
||||
|
||||
#include <sstream>
|
||||
|
@ -308,6 +307,23 @@ int CmdInfo::execute (std::string& output)
|
|||
view.set (row, 0, STRING_COLUMN_LABEL_URGENCY);
|
||||
view.set (row, 1, trimLeft (format (task->urgency (), 4, 4)));
|
||||
|
||||
// Show any UDAs
|
||||
std::vector <std::string> all = task->all ();
|
||||
std::vector <std::string>::iterator att;
|
||||
for (att = all.begin (); att != all.end (); ++att)
|
||||
{
|
||||
if (context.config.get ("uda." + *att + ".type") != "")
|
||||
{
|
||||
Column* col = context.columns[*att];
|
||||
if (col)
|
||||
{
|
||||
row = view.addRow ();
|
||||
view.set (row, 0, col->label ());
|
||||
view.set (row, 1, task->get (*att));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create a second table, containing undo log change details.
|
||||
ViewText journal;
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#define L10N // Localization complete.
|
||||
|
||||
#include <CmdInstall.h>
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#define L10N // Localization complete.
|
||||
|
||||
#include <Context.h>
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#define L10N // Localization complete.
|
||||
|
||||
#include <CmdLogo.h>
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#define L10N // Localization complete.
|
||||
|
||||
#include <fstream>
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#define L10N // Localization complete.
|
||||
|
||||
#include <sstream>
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#define L10N // Localization complete.
|
||||
|
||||
#include <fstream>
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#define L10N // Localization complete.
|
||||
|
||||
#include <fstream>
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#define L10N // Localization complete.
|
||||
|
||||
#include <sstream>
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#define L10N // Localization complete.
|
||||
|
||||
#include <iostream>
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#define L10N // Localization complete.
|
||||
|
||||
#include <vector>
|
||||
|
@ -232,6 +231,7 @@ int CmdShow::execute (std::string& output)
|
|||
i->substr (0, 5) != "push." &&
|
||||
i->substr (0, 5) != "pull." &&
|
||||
i->substr (0, 6) != "merge." &&
|
||||
i->substr (0, 4) != "uda." &&
|
||||
i->substr (0, 21) != "urgency.user.project." &&
|
||||
i->substr (0, 17) != "urgency.user.tag.")
|
||||
{
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#define L10N // Localization complete.
|
||||
|
||||
#include <sstream>
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#define L10N // Localization complete.
|
||||
|
||||
#include <sstream>
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#define L10N // Localization complete.
|
||||
|
||||
#include <sstream>
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#define L10N // Localization complete.
|
||||
|
||||
#include <Context.h>
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#define L10N // Localization complete.
|
||||
|
||||
#include <sstream>
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#define L10N // Localization complete.
|
||||
|
||||
#include <sstream>
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <stdlib.h>
|
||||
#include <Date.h>
|
||||
#include <Duration.h>
|
||||
#include <E9.h>
|
||||
#include <text.h>
|
||||
#include <util.h>
|
||||
|
@ -487,15 +489,56 @@ void Command::modify_task (
|
|||
|
||||
// If the date value is less than 5 years, it is a duration, not a
|
||||
// date, therefore add 'now'.
|
||||
long l = strtol (result.c_str (), NULL, 10);
|
||||
long l = (long) strtod (result.c_str (), NULL);
|
||||
if (labs (l) < 5 * 365 * 86400)
|
||||
{
|
||||
Duration dur (result);
|
||||
Date now;
|
||||
now += l;
|
||||
//now += dur;
|
||||
task.set (name, now.toEpochString ());
|
||||
}
|
||||
else
|
||||
{
|
||||
Date d (result, context.config.get ("dateformat"));
|
||||
task.set (name, d.toEpochString ());
|
||||
}
|
||||
}
|
||||
|
||||
// Durations too.
|
||||
else if (column->type () == "duration")
|
||||
{
|
||||
// All values must be eval'd first.
|
||||
A3 value_tokens;
|
||||
value_tokens.capture (value);
|
||||
value_tokens = value_tokens.postfix (value_tokens.tokenize (value_tokens));
|
||||
|
||||
E9 e (value_tokens);
|
||||
std::string result = e.evalExpression (task);
|
||||
context.debug (std::string ("Eval '") + value + "' --> '" + result + "'");
|
||||
|
||||
Duration d (result);
|
||||
task.set (name, result);
|
||||
}
|
||||
|
||||
// Need handling for numeric types, used by UDAs.
|
||||
else if (column->type () == "numeric")
|
||||
{
|
||||
A3 value_tokens;
|
||||
value_tokens.capture (value);
|
||||
value_tokens = value_tokens.postfix (value_tokens.tokenize (value_tokens));
|
||||
|
||||
E9 e (value_tokens);
|
||||
std::string result = e.evalExpression (task);
|
||||
context.debug (std::string ("Eval '") + value + "' --> '" + result + "'");
|
||||
|
||||
Nibbler n (result);
|
||||
double d;
|
||||
if (n.getNumber (d) &&
|
||||
n.depleted ())
|
||||
task.set (name, result);
|
||||
else
|
||||
throw format (STRING_UDA_NUMERIC, result);
|
||||
}
|
||||
|
||||
// By default, just add/remove it.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue