mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Enhancement - parse sequence like 1,3,5-10 for IDs
- Now parses sequences as well as IDs. - Sequences implemented for the info report.
This commit is contained in:
parent
d135dc2337
commit
fb674a5626
5 changed files with 52 additions and 37 deletions
13
src/T.cpp
13
src/T.cpp
|
@ -37,6 +37,7 @@ T::T ()
|
|||
mUUID = uuid ();
|
||||
mStatus = pending;
|
||||
mId = 0;
|
||||
mSequence.clear ();
|
||||
mTags.clear ();
|
||||
mAttributes.clear ();
|
||||
mDescription = "";
|
||||
|
@ -59,6 +60,7 @@ T::T (const T& other)
|
|||
mStatus = other.mStatus;
|
||||
mUUID = other.mUUID;
|
||||
mId = other.mId;
|
||||
mSequence = other.mSequence;
|
||||
mDescription = other.mDescription;
|
||||
mTags = other.mTags;
|
||||
mRemoveTags = other.mRemoveTags;
|
||||
|
@ -74,6 +76,7 @@ T& T::operator= (const T& other)
|
|||
mStatus = other.mStatus;
|
||||
mUUID = other.mUUID;
|
||||
mId = other.mId;
|
||||
mSequence = other.mSequence;
|
||||
mDescription = other.mDescription;
|
||||
mTags = other.mTags;
|
||||
mRemoveTags = other.mRemoveTags;
|
||||
|
@ -286,6 +289,16 @@ void T::addAnnotation (const std::string& description)
|
|||
mAnnotations[time (NULL)] = sanitized;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool T::inSequence (int id) const
|
||||
{
|
||||
foreach (seq, mSequence)
|
||||
if (*seq == id)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// uuid status [tags] [attributes] [annotations] description
|
||||
//
|
||||
|
|
1
src/T.h
1
src/T.h
|
@ -84,6 +84,7 @@ public:
|
|||
void getAnnotations (std::map <time_t, std::string>&) const;
|
||||
void setAnnotations (const std::map <time_t, std::string>&);
|
||||
void addAnnotation (const std::string&);
|
||||
bool inSequence (int) const;
|
||||
|
||||
const std::string compose () const;
|
||||
const std::string composeCSV ();
|
||||
|
|
|
@ -487,17 +487,9 @@ void parse (
|
|||
std::vector <int> sequence;
|
||||
|
||||
// An id is the first argument found that contains all digits.
|
||||
if (lowerCase (command) != "add" &&
|
||||
/*
|
||||
task.getSequenceCount () == 0 &&
|
||||
*/
|
||||
if (lowerCase (command) != "add" && // "add" doesn't require an ID
|
||||
validSequence (arg, sequence))
|
||||
{
|
||||
/*
|
||||
for (?)
|
||||
task.addSequence (?)
|
||||
*/
|
||||
std::cout << "# look like a sequence" << std::endl;
|
||||
foreach (id, sequence)
|
||||
task.addId (*id);
|
||||
}
|
||||
|
|
|
@ -265,35 +265,38 @@ std::string handleInfo (TDB& tdb, T& task, Config& conf)
|
|||
std::vector <T> tasks;
|
||||
tdb.allPendingT (tasks);
|
||||
|
||||
Table table;
|
||||
table.setTableWidth (width);
|
||||
table.setDateFormat (conf.get ("dateformat", "m/d/Y"));
|
||||
|
||||
table.addColumn ("Name");
|
||||
table.addColumn ("Value");
|
||||
|
||||
if (conf.get ("color", true) || conf.get (std::string ("_forcecolor"), false))
|
||||
{
|
||||
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);
|
||||
|
||||
// Find the task.
|
||||
int count = 0;
|
||||
for (unsigned int i = 0; i < tasks.size (); ++i)
|
||||
{
|
||||
T refTask (tasks[i]);
|
||||
|
||||
if (refTask.getId () == task.getId ())
|
||||
if (refTask.getId () == task.getId () ||
|
||||
task.inSequence (refTask.getId ()))
|
||||
{
|
||||
Date now;
|
||||
++count;
|
||||
|
||||
Table table;
|
||||
table.setTableWidth (width);
|
||||
table.setDateFormat (conf.get ("dateformat", "m/d/Y"));
|
||||
|
||||
table.addColumn ("Name");
|
||||
table.addColumn ("Value");
|
||||
|
||||
if (conf.get ("color", true) || conf.get (std::string ("_forcecolor"), false))
|
||||
{
|
||||
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);
|
||||
Date now;
|
||||
|
||||
int row = table.addRow ();
|
||||
table.addCell (row, 0, "ID");
|
||||
|
@ -440,14 +443,14 @@ std::string handleInfo (TDB& tdb, T& task, Config& conf)
|
|||
}
|
||||
|
||||
table.addCell (row, 1, entry + " (" + age + ")");
|
||||
|
||||
out << optionalBlankLine (conf)
|
||||
<< table.render ()
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
if (table.rowCount ())
|
||||
out << optionalBlankLine (conf)
|
||||
<< table.render ()
|
||||
<< std::endl;
|
||||
else
|
||||
if (! count)
|
||||
out << "No matches." << std::endl;
|
||||
|
||||
return out.str ();
|
||||
|
|
|
@ -227,6 +227,12 @@ static std::string longUsage (Config& conf)
|
|||
std::stringstream out;
|
||||
out << shortUsage (conf)
|
||||
<< "ID is the numeric identifier displayed by the 'task list' command." << "\n"
|
||||
<< "You can specify multiple IDs for task commands, and multiple tasks" << "\n"
|
||||
<< "will be affected. To specify multiple IDs make sure you use one" << "\n"
|
||||
<< "of these forms:" << "\n"
|
||||
<< " task delete 1,2,3" << "\n"
|
||||
<< " task info 1-3" << "\n"
|
||||
<< " task pri:H 1,2-5,19" << "\n"
|
||||
<< "\n"
|
||||
<< "Tags are arbitrary words, any quantity:" << "\n"
|
||||
<< " +tag The + means add the tag" << "\n"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue