Argument Parsing
- Eliminated stored arg_overrides and file_override in Context.
- Removed Filter, Subst, Task, Sequence from Context.
- Remove shadow file support. Hallelujah.
- Disabled/commented out most commands, ready for the big transition
to the new parsing style.
- Obsoleted Subst.{h,cpp}.
This commit is contained in:
@@ -224,8 +224,7 @@ void Arguments::categorize ()
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void Arguments::rc_override (
|
void Arguments::rc_override (
|
||||||
std::string& home,
|
std::string& home,
|
||||||
File& rc,
|
File& rc)
|
||||||
std::string& override)
|
|
||||||
{
|
{
|
||||||
// Is there an override for rc:<file>?
|
// Is there an override for rc:<file>?
|
||||||
std::vector <std::pair <std::string, std::string> >::iterator arg;
|
std::vector <std::pair <std::string, std::string> >::iterator arg;
|
||||||
@@ -233,7 +232,6 @@ void Arguments::rc_override (
|
|||||||
{
|
{
|
||||||
if (arg->second == "rc")
|
if (arg->second == "rc")
|
||||||
{
|
{
|
||||||
override = arg->first;
|
|
||||||
rc = File (arg->first.substr (3));
|
rc = File (arg->first.substr (3));
|
||||||
home = rc;
|
home = rc;
|
||||||
|
|
||||||
@@ -280,7 +278,7 @@ void Arguments::get_data_location (std::string& data)
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Extracts any rc.name:value args and sets the name/value in context.config,
|
// Extracts any rc.name:value args and sets the name/value in context.config,
|
||||||
// leaving only the plain args.
|
// leaving only the plain args.
|
||||||
void Arguments::apply_overrides (std::string& var_overrides)
|
void Arguments::apply_overrides ()
|
||||||
{
|
{
|
||||||
std::vector <std::pair <std::string, std::string> >::iterator arg;
|
std::vector <std::pair <std::string, std::string> >::iterator arg;
|
||||||
for (arg = this->begin (); arg != this->end (); ++arg)
|
for (arg = this->begin (); arg != this->end (); ++arg)
|
||||||
@@ -294,13 +292,10 @@ void Arguments::apply_overrides (std::string& var_overrides)
|
|||||||
n.getUntilOneOf (":=", name) && // xxx
|
n.getUntilOneOf (":=", name) && // xxx
|
||||||
n.skipN (1)) // :
|
n.skipN (1)) // :
|
||||||
{
|
{
|
||||||
n.getUntilEOS (value); // Don't care if it's blank.
|
n.getUntilEOS (value); // May be blank.
|
||||||
|
|
||||||
context.config.set (name, value);
|
context.config.set (name, value);
|
||||||
context.footnote ("Configuration override rc." + name + "=" + value);
|
context.footnote ("Configuration override rc." + name + "=" + value);
|
||||||
|
|
||||||
// Overrides are retained for potential use by the default command.
|
|
||||||
var_overrides += " " + arg->first;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
context.footnote ("Problem with override: " + arg->first);
|
context.footnote ("Problem with override: " + arg->first);
|
||||||
|
|||||||
@@ -45,9 +45,9 @@ public:
|
|||||||
void categorize ();
|
void categorize ();
|
||||||
|
|
||||||
void append_stdin ();
|
void append_stdin ();
|
||||||
void rc_override (std::string&, File&, std::string&);
|
void rc_override (std::string&, File&);
|
||||||
void get_data_location (std::string&);
|
void get_data_location (std::string&);
|
||||||
void apply_overrides (std::string&);
|
void apply_overrides ();
|
||||||
void resolve_aliases ();
|
void resolve_aliases ();
|
||||||
|
|
||||||
std::vector <std::string> list ();
|
std::vector <std::string> list ();
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ set (task_SRCS API.cpp API.h
|
|||||||
Permission.cpp Permission.h
|
Permission.cpp Permission.h
|
||||||
Record.cpp Record.h
|
Record.cpp Record.h
|
||||||
Sequence.cpp Sequence.h
|
Sequence.cpp Sequence.h
|
||||||
Subst.cpp Subst.h
|
|
||||||
TDB.cpp TDB.h
|
TDB.cpp TDB.h
|
||||||
TDB2.cpp TDB2.h
|
TDB2.cpp TDB2.h
|
||||||
Task.cpp Task.h
|
Task.cpp Task.h
|
||||||
|
|||||||
@@ -48,19 +48,12 @@ Context::Context ()
|
|||||||
, data_dir ()
|
, data_dir ()
|
||||||
, extension_dir ()
|
, extension_dir ()
|
||||||
, config ()
|
, config ()
|
||||||
, filter ()
|
|
||||||
, sequence ()
|
|
||||||
, subst ()
|
|
||||||
, task ()
|
|
||||||
, tdb ()
|
, tdb ()
|
||||||
, tdb2 ()
|
, tdb2 ()
|
||||||
, file_override ("")
|
|
||||||
, var_overrides ("")
|
|
||||||
, dom ()
|
, dom ()
|
||||||
, determine_color_use (true)
|
, determine_color_use (true)
|
||||||
, use_color (true)
|
, use_color (true)
|
||||||
, verbosity_legacy (false)
|
, verbosity_legacy (false)
|
||||||
, inShadow (false)
|
|
||||||
, terminal_width (0)
|
, terminal_width (0)
|
||||||
, terminal_height (0)
|
, terminal_height (0)
|
||||||
{
|
{
|
||||||
@@ -89,7 +82,7 @@ void Context::initialize (int argc, const char** argv)
|
|||||||
|
|
||||||
// Process 'rc:<file>' command line override, and remove the argument from the
|
// Process 'rc:<file>' command line override, and remove the argument from the
|
||||||
// Context::args.
|
// Context::args.
|
||||||
args.rc_override (home_dir, rc_file, file_override);
|
args.rc_override (home_dir, rc_file);
|
||||||
|
|
||||||
// Dump any existing values and load rc file.
|
// Dump any existing values and load rc file.
|
||||||
config.clear ();
|
config.clear ();
|
||||||
@@ -111,7 +104,7 @@ void Context::initialize (int argc, const char** argv)
|
|||||||
args.resolve_aliases ();
|
args.resolve_aliases ();
|
||||||
|
|
||||||
// Apply rc overrides to Context::config, capturing raw args for later use.
|
// Apply rc overrides to Context::config, capturing raw args for later use.
|
||||||
args.apply_overrides (var_overrides);
|
args.apply_overrides ();
|
||||||
|
|
||||||
// Initialize the color rules, if necessary.
|
// Initialize the color rules, if necessary.
|
||||||
if (color ())
|
if (color ())
|
||||||
@@ -356,6 +349,7 @@ void Context::shadow ()
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void Context::disallowModification () const
|
void Context::disallowModification () const
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
if (task.size () ||
|
if (task.size () ||
|
||||||
subst.mFrom != "" ||
|
subst.mFrom != "" ||
|
||||||
tagAdditions.size () ||
|
tagAdditions.size () ||
|
||||||
@@ -363,6 +357,7 @@ void Context::disallowModification () const
|
|||||||
throw std::string ("The '")
|
throw std::string ("The '")
|
||||||
// + cmd.command
|
// + cmd.command
|
||||||
+ "' command does not allow further modification of a task.";
|
+ "' command does not allow further modification of a task.";
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -412,14 +407,6 @@ void Context::loadAliases ()
|
|||||||
aliases[var->substr (6)] = config.get (*var);
|
aliases[var->substr (6)] = config.get (*var);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/*
|
|
||||||
void Context::parse ()
|
|
||||||
{
|
|
||||||
parse (args, cmd, task, sequence, subst, filter);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/*
|
/*
|
||||||
void Context::parse (
|
void Context::parse (
|
||||||
@@ -699,23 +686,11 @@ void Context::decomposeSortField (
|
|||||||
// be initialized. That makes this method something of a misnomer. So be it.
|
// be initialized. That makes this method something of a misnomer. So be it.
|
||||||
void Context::clear ()
|
void Context::clear ()
|
||||||
{
|
{
|
||||||
// Config config;
|
|
||||||
filter.clear ();
|
|
||||||
sequence.clear ();
|
|
||||||
subst.clear ();
|
|
||||||
// task.clear ();
|
|
||||||
task = Task ();
|
|
||||||
tdb.clear (); // TODO Obsolete
|
tdb.clear (); // TODO Obsolete
|
||||||
// tdb2.clear ();
|
// tdb2.clear ();
|
||||||
args.clear ();
|
args.clear ();
|
||||||
file_override = "";
|
|
||||||
var_overrides = "";
|
|
||||||
// cmd.command = ""; // TODO Obsolete
|
|
||||||
tagAdditions.clear ();
|
|
||||||
tagRemovals.clear ();
|
|
||||||
|
|
||||||
clearMessages ();
|
clearMessages ();
|
||||||
inShadow = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -804,6 +779,7 @@ void Context::autoFilter (Att& a, Filter& f)
|
|||||||
// Add all the tags in the task to the filter.
|
// Add all the tags in the task to the filter.
|
||||||
void Context::autoFilter (Filter& f)
|
void Context::autoFilter (Filter& f)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
// This is now a correct implementation of a filter on the presence or absence
|
// This is now a correct implementation of a filter on the presence or absence
|
||||||
// of a tag. The prior code provided the illusion of leftmost partial tag
|
// of a tag. The prior code provided the illusion of leftmost partial tag
|
||||||
// matches, but was really using the 'contains' and 'nocontains' attribute
|
// matches, but was really using the 'contains' and 'nocontains' attribute
|
||||||
@@ -822,6 +798,7 @@ void Context::autoFilter (Filter& f)
|
|||||||
f.push_back (Att ("tags", "noword", *tag));
|
f.push_back (Att ("tags", "noword", *tag));
|
||||||
debug ("auto filter: -" + *tag);
|
debug ("auto filter: -" + *tag);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
@@ -33,7 +33,6 @@
|
|||||||
#include <Filter.h>
|
#include <Filter.h>
|
||||||
#include <Config.h>
|
#include <Config.h>
|
||||||
#include <Sequence.h>
|
#include <Sequence.h>
|
||||||
#include <Subst.h>
|
|
||||||
#include <Task.h>
|
#include <Task.h>
|
||||||
#include <TDB.h>
|
#include <TDB.h>
|
||||||
#include <TDB2.h>
|
#include <TDB2.h>
|
||||||
@@ -68,11 +67,6 @@ public:
|
|||||||
void footnote (const std::string&); // Footnote message sink
|
void footnote (const std::string&); // Footnote message sink
|
||||||
void debug (const std::string&); // Debug message sink
|
void debug (const std::string&); // Debug message sink
|
||||||
void clearMessages ();
|
void clearMessages ();
|
||||||
|
|
||||||
/*
|
|
||||||
void parse ();
|
|
||||||
void parse (std::vector <std::string>&, Cmd&, Task&, Sequence&, Subst&, Filter&);
|
|
||||||
*/
|
|
||||||
void clear ();
|
void clear ();
|
||||||
|
|
||||||
void disallowModification () const;
|
void disallowModification () const;
|
||||||
@@ -96,17 +90,23 @@ public:
|
|||||||
Directory extension_dir;
|
Directory extension_dir;
|
||||||
Config config;
|
Config config;
|
||||||
|
|
||||||
|
/*
|
||||||
Filter filter; // TODO Obsolete
|
Filter filter; // TODO Obsolete
|
||||||
Sequence sequence; // TODO Obsolete
|
Sequence sequence; // TODO Obsolete
|
||||||
Subst subst; // TODO Obsolete
|
Subst subst; // TODO Obsolete
|
||||||
Task task; // TODO Obsolete
|
Task task; // TODO Obsolete
|
||||||
|
*/
|
||||||
TDB tdb; // TODO Obsolete
|
TDB tdb; // TODO Obsolete
|
||||||
TDB2 tdb2;
|
TDB2 tdb2;
|
||||||
|
/*
|
||||||
std::string file_override;
|
std::string file_override;
|
||||||
std::string var_overrides;
|
std::string var_overrides;
|
||||||
|
*/
|
||||||
std::map <std::string, std::string> aliases;
|
std::map <std::string, std::string> aliases;
|
||||||
|
/*
|
||||||
std::vector <std::string> tagAdditions; // TODO Obsolete
|
std::vector <std::string> tagAdditions; // TODO Obsolete
|
||||||
std::vector <std::string> tagRemovals; // TODO Obsolete
|
std::vector <std::string> tagRemovals; // TODO Obsolete
|
||||||
|
*/
|
||||||
Hooks hooks;
|
Hooks hooks;
|
||||||
DOM dom;
|
DOM dom;
|
||||||
|
|
||||||
@@ -119,7 +119,9 @@ public:
|
|||||||
std::vector <std::string> headers;
|
std::vector <std::string> headers;
|
||||||
std::vector <std::string> footnotes;
|
std::vector <std::string> footnotes;
|
||||||
std::vector <std::string> debugMessages;
|
std::vector <std::string> debugMessages;
|
||||||
|
/*
|
||||||
bool inShadow;
|
bool inShadow;
|
||||||
|
*/
|
||||||
|
|
||||||
std::map <std::string, Command*> commands;
|
std::map <std::string, Command*> commands;
|
||||||
|
|
||||||
|
|||||||
258
src/Subst.cpp
258
src/Subst.cpp
@@ -1,258 +0,0 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// taskwarrior - a command line task list manager.
|
|
||||||
//
|
|
||||||
// Copyright 2006 - 2011, Paul Beckingham, Federico Hernandez.
|
|
||||||
// All rights reserved.
|
|
||||||
//
|
|
||||||
// This program is free software; you can redistribute it and/or modify it under
|
|
||||||
// the terms of the GNU General Public License as published by the Free Software
|
|
||||||
// Foundation; either version 2 of the License, or (at your option) any later
|
|
||||||
// version.
|
|
||||||
//
|
|
||||||
// This program is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
||||||
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
||||||
// details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU General Public License along with
|
|
||||||
// this program; if not, write to the
|
|
||||||
//
|
|
||||||
// Free Software Foundation, Inc.,
|
|
||||||
// 51 Franklin Street, Fifth Floor,
|
|
||||||
// Boston, MA
|
|
||||||
// 02110-1301
|
|
||||||
// USA
|
|
||||||
//
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#include <Subst.h>
|
|
||||||
#include <Nibbler.h>
|
|
||||||
#include <Directory.h>
|
|
||||||
#include <Context.h>
|
|
||||||
#include <text.h>
|
|
||||||
#include <rx.h>
|
|
||||||
#include <i18n.h>
|
|
||||||
#include <main.h>
|
|
||||||
|
|
||||||
extern Context context;
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
Subst::Subst ()
|
|
||||||
: mFrom ("")
|
|
||||||
, mTo ("")
|
|
||||||
, mGlobal (false)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
Subst::Subst (const std::string& input)
|
|
||||||
{
|
|
||||||
parse (input);
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
Subst::Subst (const Subst& other)
|
|
||||||
{
|
|
||||||
mFrom = other.mFrom;
|
|
||||||
mTo = other.mTo;
|
|
||||||
mGlobal = other.mGlobal;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
Subst& Subst::operator= (const Subst& other)
|
|
||||||
{
|
|
||||||
if (this != &other)
|
|
||||||
{
|
|
||||||
mFrom = other.mFrom;
|
|
||||||
mTo = other.mTo;
|
|
||||||
mGlobal = other.mGlobal;
|
|
||||||
}
|
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
Subst::~Subst ()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// A Path and a Subst may look similar, and so the rule is that if a Subst looks
|
|
||||||
// like a path, it must also not exist in the file system in order to actually
|
|
||||||
// be a Subst.
|
|
||||||
bool Subst::valid (const std::string& input) const
|
|
||||||
{
|
|
||||||
std::string ignored;
|
|
||||||
Nibbler n (input);
|
|
||||||
if (n.skip ('/') &&
|
|
||||||
n.getUntil ('/', ignored) &&
|
|
||||||
n.skip ('/') &&
|
|
||||||
n.getUntil ('/', ignored) &&
|
|
||||||
n.skip ('/'))
|
|
||||||
{
|
|
||||||
n.skip ('g');
|
|
||||||
if (n.depleted ())
|
|
||||||
return ! Directory (input).exists ();
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
void Subst::parse (const std::string& input)
|
|
||||||
{
|
|
||||||
Nibbler n (input);
|
|
||||||
if (n.skip ('/') &&
|
|
||||||
n.getUntil ('/', mFrom) &&
|
|
||||||
n.skip ('/') &&
|
|
||||||
n.getUntil ('/', mTo) &&
|
|
||||||
n.skip ('/'))
|
|
||||||
{
|
|
||||||
mGlobal = n.skip ('g');
|
|
||||||
|
|
||||||
if (mFrom == "")
|
|
||||||
throw std::string ("Cannot substitute an empty string.");
|
|
||||||
|
|
||||||
if (!n.depleted ())
|
|
||||||
throw std::string ("Unrecognized character(s) at end of substitution.");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
throw std::string ("Malformed substitution.");
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
void Subst::apply (
|
|
||||||
std::string& description,
|
|
||||||
std::vector <Att>& annotations) const
|
|
||||||
{
|
|
||||||
std::string::size_type pattern;
|
|
||||||
bool sensitive = context.config.getBoolean ("search.case.sensitive");
|
|
||||||
|
|
||||||
if (mFrom != "")
|
|
||||||
{
|
|
||||||
#ifdef FEATURE_REGEX
|
|
||||||
if (context.config.getBoolean ("regex"))
|
|
||||||
{
|
|
||||||
// Insert capturing parentheses, if necessary.
|
|
||||||
std::string pattern;
|
|
||||||
if (mFrom.find ('(') != std::string::npos)
|
|
||||||
pattern = mFrom;
|
|
||||||
else
|
|
||||||
pattern = "(" + mFrom + ")";
|
|
||||||
|
|
||||||
std::vector <int> start;
|
|
||||||
std::vector <int> end;
|
|
||||||
|
|
||||||
// Perform all subs on description.
|
|
||||||
int counter = 0;
|
|
||||||
if (regexMatch (start, end, description, pattern, sensitive))
|
|
||||||
{
|
|
||||||
for (unsigned int i = 0; i < start.size (); ++i)
|
|
||||||
{
|
|
||||||
description.replace (start[i], end[i] - start[i], mTo);
|
|
||||||
if (!mGlobal)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (++counter > 1000)
|
|
||||||
throw ("Terminated substitution because more than a thousand changes were made - infinite loop protection.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Perform all subs on annotations.
|
|
||||||
counter = 0;
|
|
||||||
std::vector <Att>::iterator i;
|
|
||||||
for (i = annotations.begin (); i != annotations.end (); ++i)
|
|
||||||
{
|
|
||||||
std::string annotation = i->value ();
|
|
||||||
start.clear ();
|
|
||||||
end.clear ();
|
|
||||||
|
|
||||||
if (regexMatch (start, end, annotation, pattern, sensitive))
|
|
||||||
{
|
|
||||||
for (unsigned int match = 0; match < start.size (); ++match)
|
|
||||||
{
|
|
||||||
annotation.replace (start[match], end[match] - start[match], mTo);
|
|
||||||
i->value (annotation);
|
|
||||||
if (!mGlobal)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (++counter > 1000)
|
|
||||||
throw ("Terminated substitution because more than a thousand changes were made - infinite loop protection.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
#endif
|
|
||||||
if (mGlobal)
|
|
||||||
{
|
|
||||||
// Perform all subs on description.
|
|
||||||
int counter = 0;
|
|
||||||
pattern = 0;
|
|
||||||
|
|
||||||
while ((pattern = find (description, mFrom, pattern, sensitive)) != std::string::npos)
|
|
||||||
{
|
|
||||||
description.replace (pattern, mFrom.length (), mTo);
|
|
||||||
pattern += mTo.length ();
|
|
||||||
|
|
||||||
if (++counter > 1000)
|
|
||||||
throw ("Terminated substitution because more than a thousand changes were made - infinite loop protection.");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Perform all subs on annotations.
|
|
||||||
counter = 0;
|
|
||||||
std::vector <Att>::iterator i;
|
|
||||||
for (i = annotations.begin (); i != annotations.end (); ++i)
|
|
||||||
{
|
|
||||||
pattern = 0;
|
|
||||||
std::string annotation = i->value ();
|
|
||||||
while ((pattern = find (annotation, mFrom, pattern, sensitive)) != std::string::npos)
|
|
||||||
{
|
|
||||||
annotation.replace (pattern, mFrom.length (), mTo);
|
|
||||||
pattern += mTo.length ();
|
|
||||||
|
|
||||||
i->value (annotation);
|
|
||||||
|
|
||||||
if (++counter > 1000)
|
|
||||||
throw ("Terminated substitution because more than a thousand changes were made - infinite loop protection.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Perform first description substitution.
|
|
||||||
if ((pattern = find (description, mFrom, sensitive)) != std::string::npos)
|
|
||||||
description.replace (pattern, mFrom.length (), mTo);
|
|
||||||
|
|
||||||
// Failing that, perform the first annotation substitution.
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::vector <Att>::iterator i;
|
|
||||||
for (i = annotations.begin (); i != annotations.end (); ++i)
|
|
||||||
{
|
|
||||||
std::string annotation = i->value ();
|
|
||||||
if ((pattern = find (annotation, mFrom, sensitive)) != std::string::npos)
|
|
||||||
{
|
|
||||||
annotation.replace (pattern, mFrom.length (), mTo);
|
|
||||||
i->value (annotation);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#ifdef FEATURE_REGEX
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
void Subst::clear ()
|
|
||||||
{
|
|
||||||
mFrom = "";
|
|
||||||
mTo = "";
|
|
||||||
mGlobal = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
55
src/Subst.h
55
src/Subst.h
@@ -1,55 +0,0 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// taskwarrior - a command line task list manager.
|
|
||||||
//
|
|
||||||
// Copyright 2006 - 2011, Paul Beckingham, Federico Hernandez.
|
|
||||||
// All rights reserved.
|
|
||||||
//
|
|
||||||
// This program is free software; you can redistribute it and/or modify it under
|
|
||||||
// the terms of the GNU General Public License as published by the Free Software
|
|
||||||
// Foundation; either version 2 of the License, or (at your option) any later
|
|
||||||
// version.
|
|
||||||
//
|
|
||||||
// This program is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
||||||
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
||||||
// details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU General Public License along with
|
|
||||||
// this program; if not, write to the
|
|
||||||
//
|
|
||||||
// Free Software Foundation, Inc.,
|
|
||||||
// 51 Franklin Street, Fifth Floor,
|
|
||||||
// Boston, MA
|
|
||||||
// 02110-1301
|
|
||||||
// USA
|
|
||||||
//
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
#ifndef INCLUDED_SUBST
|
|
||||||
#define INCLUDED_SUBST
|
|
||||||
#define L10N // Localization complete.
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <Att.h>
|
|
||||||
|
|
||||||
class Subst
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Subst (); // Default constructor
|
|
||||||
Subst (const std::string&); // Default constructor
|
|
||||||
Subst (const Subst&); // Copy constructor
|
|
||||||
Subst& operator= (const Subst&); // Assignment operator
|
|
||||||
~Subst (); // Destructor
|
|
||||||
|
|
||||||
bool valid (const std::string&) const;
|
|
||||||
void parse (const std::string&);
|
|
||||||
void apply (std::string&, std::vector <Att>&) const;
|
|
||||||
void clear ();
|
|
||||||
|
|
||||||
public:
|
|
||||||
std::string mFrom;
|
|
||||||
std::string mTo;
|
|
||||||
bool mGlobal;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
@@ -30,7 +30,6 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <Record.h>
|
#include <Record.h>
|
||||||
#include <Subst.h>
|
|
||||||
#include <Sequence.h>
|
#include <Sequence.h>
|
||||||
|
|
||||||
class Task : public Record
|
class Task : public Record
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ CmdAdd::CmdAdd ()
|
|||||||
int CmdAdd::execute (std::string& output)
|
int CmdAdd::execute (std::string& output)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
/*
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
|
|
||||||
context.task.set ("uuid", uuid ());
|
context.task.set ("uuid", uuid ());
|
||||||
@@ -141,6 +142,7 @@ int CmdAdd::execute (std::string& output)
|
|||||||
context.tdb.unlock ();
|
context.tdb.unlock ();
|
||||||
|
|
||||||
output = out.str ();
|
output = out.str ();
|
||||||
|
*/
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ int CmdAnnotate::execute (std::string& output)
|
|||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
if (!context.task.has ("description"))
|
if (!context.task.has ("description"))
|
||||||
throw std::string ("Cannot apply a blank annotation.");
|
throw std::string ("Cannot apply a blank annotation.");
|
||||||
|
|
||||||
@@ -102,6 +103,7 @@ int CmdAnnotate::execute (std::string& output)
|
|||||||
context.tdb.unlock ();
|
context.tdb.unlock ();
|
||||||
|
|
||||||
output = out.str ();
|
output = out.str ();
|
||||||
|
*/
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,10 +46,13 @@ CmdAppend::CmdAppend ()
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
int CmdAppend::execute (std::string& output)
|
int CmdAppend::execute (std::string& output)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
if (!context.task.has ("description"))
|
if (!context.task.has ("description"))
|
||||||
throw std::string ("Additional text must be provided.");
|
throw std::string ("Additional text must be provided.");
|
||||||
|
*/
|
||||||
|
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
/*
|
||||||
int count = 0;
|
int count = 0;
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
|
|
||||||
@@ -126,6 +129,7 @@ int CmdAppend::execute (std::string& output)
|
|||||||
out << "Appended " << count << " task" << (count == 1 ? ".\n" : "s.\n");
|
out << "Appended " << count << " task" << (count == 1 ? ".\n" : "s.\n");
|
||||||
|
|
||||||
output = out.str ();
|
output = out.str ();
|
||||||
|
*/
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -982,6 +982,7 @@ int CmdBurndownMonthly::execute (std::string& output)
|
|||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
// Scan the pending tasks, applying any filter.
|
// Scan the pending tasks, applying any filter.
|
||||||
std::vector <Task> tasks;
|
std::vector <Task> tasks;
|
||||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||||
@@ -1017,6 +1018,7 @@ int CmdBurndownMonthly::execute (std::string& output)
|
|||||||
|
|
||||||
chart.scan (tasks);
|
chart.scan (tasks);
|
||||||
output = chart.render ();
|
output = chart.render ();
|
||||||
|
*/
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1035,6 +1037,7 @@ int CmdBurndownWeekly::execute (std::string& output)
|
|||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
// Scan the pending tasks, applying any filter.
|
// Scan the pending tasks, applying any filter.
|
||||||
std::vector <Task> tasks;
|
std::vector <Task> tasks;
|
||||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||||
@@ -1070,6 +1073,7 @@ int CmdBurndownWeekly::execute (std::string& output)
|
|||||||
|
|
||||||
chart.scan (tasks);
|
chart.scan (tasks);
|
||||||
output = chart.render ();
|
output = chart.render ();
|
||||||
|
*/
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1088,6 +1092,7 @@ int CmdBurndownDaily::execute (std::string& output)
|
|||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
// Scan the pending tasks, applying any filter.
|
// Scan the pending tasks, applying any filter.
|
||||||
std::vector <Task> tasks;
|
std::vector <Task> tasks;
|
||||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||||
@@ -1123,6 +1128,7 @@ int CmdBurndownDaily::execute (std::string& output)
|
|||||||
|
|
||||||
chart.scan (tasks);
|
chart.scan (tasks);
|
||||||
output = chart.render ();
|
output = chart.render ();
|
||||||
|
*/
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ int CmdCalendar::execute (std::string& output)
|
|||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
// Each month requires 28 text columns width. See how many will actually
|
// Each month requires 28 text columns width. See how many will actually
|
||||||
// fit. But if a preference is specified, and it fits, use it.
|
// fit. But if a preference is specified, and it fits, use it.
|
||||||
int width = context.getWidth ();
|
int width = context.getWidth ();
|
||||||
@@ -401,6 +402,7 @@ int CmdCalendar::execute (std::string& output)
|
|||||||
}
|
}
|
||||||
|
|
||||||
output = out.str ();
|
output = out.str ();
|
||||||
|
*/
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ CmdColor::CmdColor ()
|
|||||||
int CmdColor::execute (std::string& output)
|
int CmdColor::execute (std::string& output)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
/*
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
|
|
||||||
if (context.color ())
|
if (context.color ())
|
||||||
@@ -239,6 +240,7 @@ int CmdColor::execute (std::string& output)
|
|||||||
}
|
}
|
||||||
|
|
||||||
output = out.str ();
|
output = out.str ();
|
||||||
|
*/
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ CmdCount::CmdCount ()
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
int CmdCount::execute (std::string& output)
|
int CmdCount::execute (std::string& output)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
// Scan the pending tasks, applying any filter.
|
// Scan the pending tasks, applying any filter.
|
||||||
std::vector <Task> tasks;
|
std::vector <Task> tasks;
|
||||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||||
@@ -63,6 +64,7 @@ int CmdCount::execute (std::string& output)
|
|||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
out << count << "\n";
|
out << count << "\n";
|
||||||
output = out.str ();
|
output = out.str ();
|
||||||
|
*/
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -321,6 +321,7 @@ void CmdCustom::getLimits (const std::string& report, int& rows, int& lines)
|
|||||||
|
|
||||||
// If the custom report has a defined limit, then allow a numeric override.
|
// If the custom report has a defined limit, then allow a numeric override.
|
||||||
// This is an integer specified as a filter (limit:10).
|
// This is an integer specified as a filter (limit:10).
|
||||||
|
/*
|
||||||
if (context.task.has ("limit"))
|
if (context.task.has ("limit"))
|
||||||
{
|
{
|
||||||
if (context.task.get ("limit") == "page")
|
if (context.task.get ("limit") == "page")
|
||||||
@@ -337,6 +338,7 @@ void CmdCustom::getLimits (const std::string& report, int& rows, int& lines)
|
|||||||
lines = 0;
|
lines = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ CmdDelete::CmdDelete ()
|
|||||||
int CmdDelete::execute (std::string& output)
|
int CmdDelete::execute (std::string& output)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
/*
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
|
|
||||||
context.disallowModification ();
|
context.disallowModification ();
|
||||||
@@ -184,6 +185,7 @@ int CmdDelete::execute (std::string& output)
|
|||||||
context.tdb.unlock ();
|
context.tdb.unlock ();
|
||||||
|
|
||||||
output = out.str ();
|
output = out.str ();
|
||||||
|
*/
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ int CmdDenotate::execute (std::string& output)
|
|||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
if (!context.task.has ("description"))
|
if (!context.task.has ("description"))
|
||||||
throw std::string ("Description needed to delete an annotation.");
|
throw std::string ("Description needed to delete an annotation.");
|
||||||
|
|
||||||
@@ -141,6 +142,7 @@ int CmdDenotate::execute (std::string& output)
|
|||||||
context.tdb.unlock ();
|
context.tdb.unlock ();
|
||||||
|
|
||||||
output = out.str ();
|
output = out.str ();
|
||||||
|
*/
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ CmdDone::CmdDone ()
|
|||||||
int CmdDone::execute (std::string& output)
|
int CmdDone::execute (std::string& output)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
/*
|
||||||
int count = 0;
|
int count = 0;
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
|
|
||||||
@@ -149,6 +150,7 @@ int CmdDone::execute (std::string& output)
|
|||||||
<< " as done.\n";
|
<< " as done.\n";
|
||||||
|
|
||||||
output = out.str ();
|
output = out.str ();
|
||||||
|
*/
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ CmdDuplicate::CmdDuplicate ()
|
|||||||
int CmdDuplicate::execute (std::string& output)
|
int CmdDuplicate::execute (std::string& output)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
/*
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
@@ -135,6 +136,7 @@ int CmdDuplicate::execute (std::string& output)
|
|||||||
context.tdb.unlock ();
|
context.tdb.unlock ();
|
||||||
|
|
||||||
output = out.str ();
|
output = out.str ();
|
||||||
|
*/
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ int CmdEdit::execute (std::string& output)
|
|||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
|
|
||||||
std::vector <Task> tasks;
|
std::vector <Task> tasks;
|
||||||
@@ -77,6 +78,7 @@ int CmdEdit::execute (std::string& output)
|
|||||||
context.tdb.unlock ();
|
context.tdb.unlock ();
|
||||||
|
|
||||||
output = out.str ();
|
output = out.str ();
|
||||||
|
*/
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ CmdHistoryMonthly::CmdHistoryMonthly ()
|
|||||||
int CmdHistoryMonthly::execute (std::string& output)
|
int CmdHistoryMonthly::execute (std::string& output)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
/*
|
||||||
std::map <time_t, int> groups; // Represents any month with data
|
std::map <time_t, int> groups; // Represents any month with data
|
||||||
std::map <time_t, int> addedGroup; // Additions by month
|
std::map <time_t, int> addedGroup; // Additions by month
|
||||||
std::map <time_t, int> completedGroup; // Completions by month
|
std::map <time_t, int> completedGroup; // Completions by month
|
||||||
@@ -187,6 +188,7 @@ int CmdHistoryMonthly::execute (std::string& output)
|
|||||||
}
|
}
|
||||||
|
|
||||||
output = out.str ();
|
output = out.str ();
|
||||||
|
*/
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -204,6 +206,7 @@ CmdHistoryAnnual::CmdHistoryAnnual ()
|
|||||||
int CmdHistoryAnnual::execute (std::string& output)
|
int CmdHistoryAnnual::execute (std::string& output)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
/*
|
||||||
std::map <time_t, int> groups; // Represents any month with data
|
std::map <time_t, int> groups; // Represents any month with data
|
||||||
std::map <time_t, int> addedGroup; // Additions by month
|
std::map <time_t, int> addedGroup; // Additions by month
|
||||||
std::map <time_t, int> completedGroup; // Completions by month
|
std::map <time_t, int> completedGroup; // Completions by month
|
||||||
@@ -340,6 +343,7 @@ int CmdHistoryAnnual::execute (std::string& output)
|
|||||||
}
|
}
|
||||||
|
|
||||||
output = out.str ();
|
output = out.str ();
|
||||||
|
*/
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -357,6 +361,7 @@ CmdGHistoryMonthly::CmdGHistoryMonthly ()
|
|||||||
int CmdGHistoryMonthly::execute (std::string& output)
|
int CmdGHistoryMonthly::execute (std::string& output)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
/*
|
||||||
std::map <time_t, int> groups; // Represents any month with data
|
std::map <time_t, int> groups; // Represents any month with data
|
||||||
std::map <time_t, int> addedGroup; // Additions by month
|
std::map <time_t, int> addedGroup; // Additions by month
|
||||||
std::map <time_t, int> completedGroup; // Completions by month
|
std::map <time_t, int> completedGroup; // Completions by month
|
||||||
@@ -536,6 +541,7 @@ int CmdGHistoryMonthly::execute (std::string& output)
|
|||||||
}
|
}
|
||||||
|
|
||||||
output = out.str ();
|
output = out.str ();
|
||||||
|
*/
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -553,6 +559,7 @@ CmdGHistoryAnnual::CmdGHistoryAnnual ()
|
|||||||
int CmdGHistoryAnnual::execute (std::string& output)
|
int CmdGHistoryAnnual::execute (std::string& output)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
/*
|
||||||
std::map <time_t, int> groups; // Represents any month with data
|
std::map <time_t, int> groups; // Represents any month with data
|
||||||
std::map <time_t, int> addedGroup; // Additions by month
|
std::map <time_t, int> addedGroup; // Additions by month
|
||||||
std::map <time_t, int> completedGroup; // Completions by month
|
std::map <time_t, int> completedGroup; // Completions by month
|
||||||
@@ -729,6 +736,7 @@ int CmdGHistoryAnnual::execute (std::string& output)
|
|||||||
}
|
}
|
||||||
|
|
||||||
output = out.str ();
|
output = out.str ();
|
||||||
|
*/
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ CmdIDs::CmdIDs ()
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
int CmdIDs::execute (std::string& output)
|
int CmdIDs::execute (std::string& output)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
// Scan the pending tasks, applying any filter.
|
// Scan the pending tasks, applying any filter.
|
||||||
std::vector <Task> tasks;
|
std::vector <Task> tasks;
|
||||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||||
@@ -64,6 +65,7 @@ int CmdIDs::execute (std::string& output)
|
|||||||
|
|
||||||
std::sort (ids.begin (), ids.end ());
|
std::sort (ids.begin (), ids.end ());
|
||||||
output = compressIds (ids) + "\n";
|
output = compressIds (ids) + "\n";
|
||||||
|
*/
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1287,6 +1287,7 @@ std::string CmdImport::YAML (const std::vector <std::string>& lines)
|
|||||||
int CmdImport::execute (std::string& output)
|
int CmdImport::execute (std::string& output)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
/*
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
|
|
||||||
// Use the description as a file name.
|
// Use the description as a file name.
|
||||||
@@ -1359,7 +1360,7 @@ int CmdImport::execute (std::string& output)
|
|||||||
case type_csv: out << CSV (lines); break;
|
case type_csv: out << CSV (lines); break;
|
||||||
case type_yaml: out << YAML (lines); break;
|
case type_yaml: out << YAML (lines); break;
|
||||||
case type_text: out << text (lines); break;
|
case type_text: out << text (lines); break;
|
||||||
case type_not_a_clue: /* to stop the compiler from complaining. */ break;
|
case type_not_a_clue: break; // To stifle gcc.
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tmpfile != "")
|
if (tmpfile != "")
|
||||||
@@ -1369,6 +1370,7 @@ int CmdImport::execute (std::string& output)
|
|||||||
throw std::string ("You must specify a file to import.");
|
throw std::string ("You must specify a file to import.");
|
||||||
|
|
||||||
output = out.str ();
|
output = out.str ();
|
||||||
|
*/
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ int CmdInfo::execute (std::string& output)
|
|||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
// Get all the tasks.
|
// Get all the tasks.
|
||||||
std::vector <Task> tasks;
|
std::vector <Task> tasks;
|
||||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||||
@@ -397,6 +398,7 @@ int CmdInfo::execute (std::string& output)
|
|||||||
}
|
}
|
||||||
|
|
||||||
output = out.str ();
|
output = out.str ();
|
||||||
|
*/
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ CmdLog::CmdLog ()
|
|||||||
int CmdLog::execute (std::string& output)
|
int CmdLog::execute (std::string& output)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
/*
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
|
|
||||||
context.task.setStatus (Task::completed);
|
context.task.setStatus (Task::completed);
|
||||||
@@ -109,6 +110,7 @@ int CmdLog::execute (std::string& output)
|
|||||||
context.tdb.unlock ();
|
context.tdb.unlock ();
|
||||||
|
|
||||||
output = out.str ();
|
output = out.str ();
|
||||||
|
*/
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ CmdMerge::CmdMerge ()
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
int CmdMerge::execute (std::string& output)
|
int CmdMerge::execute (std::string& output)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
std::string file = trim (context.task.get ("description"));
|
std::string file = trim (context.task.get ("description"));
|
||||||
std::string pushfile = "";
|
std::string pushfile = "";
|
||||||
std::string tmpfile = "";
|
std::string tmpfile = "";
|
||||||
@@ -100,6 +101,7 @@ int CmdMerge::execute (std::string& output)
|
|||||||
throw std::string ("No uri was specified for the merge. Either specify "
|
throw std::string ("No uri was specified for the merge. Either specify "
|
||||||
"the uri of a remote .task directory, or create a "
|
"the uri of a remote .task directory, or create a "
|
||||||
"'merge.default.uri' entry in your .taskrc file.");
|
"'merge.default.uri' entry in your .taskrc file.");
|
||||||
|
*/
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ CmdModify::CmdModify ()
|
|||||||
int CmdModify::execute (std::string& output)
|
int CmdModify::execute (std::string& output)
|
||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
/*
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
|
|
||||||
std::vector <Task> tasks;
|
std::vector <Task> tasks;
|
||||||
@@ -181,6 +182,7 @@ int CmdModify::execute (std::string& output)
|
|||||||
out << "Modified " << count << " task" << (count == 1 ? ".\n" : "s.\n");
|
out << "Modified " << count << " task" << (count == 1 ? ".\n" : "s.\n");
|
||||||
|
|
||||||
output = out.str ();
|
output = out.str ();
|
||||||
|
*/
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,10 +46,13 @@ CmdPrepend::CmdPrepend ()
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
int CmdPrepend::execute (std::string& output)
|
int CmdPrepend::execute (std::string& output)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
if (!context.task.has ("description"))
|
if (!context.task.has ("description"))
|
||||||
throw std::string ("Additional text must be provided.");
|
throw std::string ("Additional text must be provided.");
|
||||||
|
*/
|
||||||
|
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
/*
|
||||||
int count = 0;
|
int count = 0;
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
|
|
||||||
@@ -126,6 +129,7 @@ int CmdPrepend::execute (std::string& output)
|
|||||||
out << "Prepended " << count << " task" << (count == 1 ? ".\n" : "s.\n");
|
out << "Prepended " << count << " task" << (count == 1 ? ".\n" : "s.\n");
|
||||||
|
|
||||||
output = out.str ();
|
output = out.str ();
|
||||||
|
*/
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ CmdProjects::CmdProjects ()
|
|||||||
int CmdProjects::execute (std::string& output)
|
int CmdProjects::execute (std::string& output)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
/*
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
|
|
||||||
std::vector <Task> tasks;
|
std::vector <Task> tasks;
|
||||||
@@ -128,6 +129,7 @@ int CmdProjects::execute (std::string& output)
|
|||||||
}
|
}
|
||||||
|
|
||||||
output = out.str ();
|
output = out.str ();
|
||||||
|
*/
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,6 +146,7 @@ CmdCompletionProjects::CmdCompletionProjects ()
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
int CmdCompletionProjects::execute (std::string& output)
|
int CmdCompletionProjects::execute (std::string& output)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
std::vector <Task> tasks;
|
std::vector <Task> tasks;
|
||||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||||
|
|
||||||
@@ -167,6 +170,7 @@ int CmdCompletionProjects::execute (std::string& output)
|
|||||||
for (project = unique.begin (); project != unique.end (); ++project)
|
for (project = unique.begin (); project != unique.end (); ++project)
|
||||||
if (project->first.length ())
|
if (project->first.length ())
|
||||||
output += project->first + "\n";
|
output += project->first + "\n";
|
||||||
|
*/
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ CmdPull::CmdPull ()
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
int CmdPull::execute (std::string& output)
|
int CmdPull::execute (std::string& output)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
std::string file = trim (context.task.get ("description"));
|
std::string file = trim (context.task.get ("description"));
|
||||||
|
|
||||||
Uri uri (file, "pull");
|
Uri uri (file, "pull");
|
||||||
@@ -111,6 +112,7 @@ int CmdPull::execute (std::string& output)
|
|||||||
throw std::string ("No uri was specified for the pull. Either specify "
|
throw std::string ("No uri was specified for the pull. Either specify "
|
||||||
"the uri of a remote .task directory, or create a "
|
"the uri of a remote .task directory, or create a "
|
||||||
"'pull.default.uri' entry in your .taskrc file.");
|
"'pull.default.uri' entry in your .taskrc file.");
|
||||||
|
*/
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ CmdPush::CmdPush ()
|
|||||||
// this is potentially on another machine, no checking can be performed.
|
// this is potentially on another machine, no checking can be performed.
|
||||||
int CmdPush::execute (std::string& output)
|
int CmdPush::execute (std::string& output)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
std::string file = trim (context.task.get ("description"));
|
std::string file = trim (context.task.get ("description"));
|
||||||
|
|
||||||
Uri uri (file, "push");
|
Uri uri (file, "push");
|
||||||
@@ -95,6 +96,7 @@ int CmdPush::execute (std::string& output)
|
|||||||
throw std::string ("No uri was specified for the push. Either specify "
|
throw std::string ("No uri was specified for the push. Either specify "
|
||||||
"the uri of a remote .task directory, or create a "
|
"the uri of a remote .task directory, or create a "
|
||||||
"'push.default.uri' entry in your .taskrc file.");
|
"'push.default.uri' entry in your .taskrc file.");
|
||||||
|
*/
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ int CmdQuery::execute (std::string& output)
|
|||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
// Get all the tasks.
|
// Get all the tasks.
|
||||||
std::vector <Task> tasks;
|
std::vector <Task> tasks;
|
||||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||||
@@ -77,6 +78,7 @@ int CmdQuery::execute (std::string& output)
|
|||||||
}
|
}
|
||||||
|
|
||||||
output += "\n";
|
output += "\n";
|
||||||
|
*/
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ CmdShell::CmdShell ()
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
int CmdShell::execute (std::string&)
|
int CmdShell::execute (std::string&)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
// Display some kind of welcome message.
|
// Display some kind of welcome message.
|
||||||
Color bold (Color::nocolor, Color::nocolor, false, true, false);
|
Color bold (Color::nocolor, Color::nocolor, false, true, false);
|
||||||
std::cout << (context.color () ? bold.colorize (PACKAGE_STRING) : PACKAGE_STRING)
|
std::cout << (context.color () ? bold.colorize (PACKAGE_STRING) : PACKAGE_STRING)
|
||||||
@@ -85,17 +86,15 @@ int CmdShell::execute (std::string&)
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
/*
|
// context.clear ();
|
||||||
context.clear ();
|
// std::vector <std::string> args;
|
||||||
std::vector <std::string> args;
|
// split (args, decoratedCommand, ' ');
|
||||||
split (args, decoratedCommand, ' ');
|
// std::vector <std::string>::iterator arg;
|
||||||
std::vector <std::string>::iterator arg;
|
// for (arg = args.begin (); arg != args.end (); ++arg)
|
||||||
for (arg = args.begin (); arg != args.end (); ++arg)
|
// context.args.push_back (*arg);
|
||||||
context.args.push_back (*arg);
|
//
|
||||||
|
// context.initialize (0, NULL);
|
||||||
context.initialize (0, NULL);
|
// context.run ();
|
||||||
context.run ();
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
catch (std::string& error)
|
catch (std::string& error)
|
||||||
@@ -113,6 +112,7 @@ int CmdShell::execute (std::string&)
|
|||||||
|
|
||||||
// No need to repeat any overrides after the shell quits.
|
// No need to repeat any overrides after the shell quits.
|
||||||
context.clearMessages ();
|
context.clearMessages ();
|
||||||
|
*/
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ CmdStart::CmdStart ()
|
|||||||
int CmdStart::execute (std::string& output)
|
int CmdStart::execute (std::string& output)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
/*
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
|
|
||||||
context.disallowModification ();
|
context.disallowModification ();
|
||||||
@@ -105,6 +106,7 @@ int CmdStart::execute (std::string& output)
|
|||||||
context.tdb.unlock ();
|
context.tdb.unlock ();
|
||||||
|
|
||||||
output = out.str ();
|
output = out.str ();
|
||||||
|
*/
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ CmdStatistics::CmdStatistics ()
|
|||||||
int CmdStatistics::execute (std::string& output)
|
int CmdStatistics::execute (std::string& output)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
/*
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
|
|
||||||
// Go get the file sizes.
|
// Go get the file sizes.
|
||||||
@@ -273,6 +274,7 @@ int CmdStatistics::execute (std::string& output)
|
|||||||
<< optionalBlankLine ();
|
<< optionalBlankLine ();
|
||||||
|
|
||||||
output = out.str ();
|
output = out.str ();
|
||||||
|
*/
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ CmdStop::CmdStop ()
|
|||||||
int CmdStop::execute (std::string& output)
|
int CmdStop::execute (std::string& output)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
/*
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
|
|
||||||
context.disallowModification ();
|
context.disallowModification ();
|
||||||
@@ -97,6 +98,7 @@ int CmdStop::execute (std::string& output)
|
|||||||
context.tdb.unlock ();
|
context.tdb.unlock ();
|
||||||
|
|
||||||
output = out.str ();
|
output = out.str ();
|
||||||
|
*/
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ int CmdSummary::execute (std::string& output)
|
|||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
// Scan the pending tasks.
|
// Scan the pending tasks.
|
||||||
std::vector <Task> tasks;
|
std::vector <Task> tasks;
|
||||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||||
@@ -175,6 +176,7 @@ int CmdSummary::execute (std::string& output)
|
|||||||
}
|
}
|
||||||
|
|
||||||
output = out.str ();
|
output = out.str ();
|
||||||
|
*/
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ CmdTags::CmdTags ()
|
|||||||
int CmdTags::execute (std::string& output)
|
int CmdTags::execute (std::string& output)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
/*
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
|
|
||||||
std::vector <Task> tasks;
|
std::vector <Task> tasks;
|
||||||
@@ -117,6 +118,7 @@ int CmdTags::execute (std::string& output)
|
|||||||
}
|
}
|
||||||
|
|
||||||
output = out.str ();
|
output = out.str ();
|
||||||
|
*/
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,6 +135,7 @@ CmdCompletionTags::CmdCompletionTags ()
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
int CmdCompletionTags::execute (std::string& output)
|
int CmdCompletionTags::execute (std::string& output)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
std::vector <Task> tasks;
|
std::vector <Task> tasks;
|
||||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||||
|
|
||||||
@@ -173,6 +176,7 @@ int CmdCompletionTags::execute (std::string& output)
|
|||||||
out << it->first << "\n";
|
out << it->first << "\n";
|
||||||
|
|
||||||
output = out.str ();
|
output = out.str ();
|
||||||
|
*/
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ int CmdTimesheet::execute (std::string& output)
|
|||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
// Scan the pending tasks.
|
// Scan the pending tasks.
|
||||||
std::vector <Task> tasks;
|
std::vector <Task> tasks;
|
||||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||||
@@ -179,6 +180,7 @@ int CmdTimesheet::execute (std::string& output)
|
|||||||
}
|
}
|
||||||
|
|
||||||
output = out.str ();
|
output = out.str ();
|
||||||
|
*/
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ CmdUrgency::CmdUrgency ()
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
int CmdUrgency::execute (std::string& output)
|
int CmdUrgency::execute (std::string& output)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
// Get all the tasks.
|
// Get all the tasks.
|
||||||
std::vector <Task> tasks;
|
std::vector <Task> tasks;
|
||||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||||
@@ -73,6 +74,7 @@ int CmdUrgency::execute (std::string& output)
|
|||||||
<< "\n";
|
<< "\n";
|
||||||
|
|
||||||
output = out.str ();
|
output = out.str ();
|
||||||
|
*/
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
163
src/helpers.cpp
163
src/helpers.cpp
@@ -197,21 +197,22 @@ static void countTasks (
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (skip == 0)
|
if (skip == 0)
|
||||||
{
|
{
|
||||||
switch (it->getStatus ())
|
switch (it->getStatus ())
|
||||||
{
|
{
|
||||||
case Task::pending:
|
case Task::pending:
|
||||||
case Task::waiting:
|
case Task::waiting:
|
||||||
++count_pending;
|
++count_pending;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Task::completed:
|
case Task::completed:
|
||||||
++count_done;
|
++count_done;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -221,25 +222,28 @@ static void countTasks (
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
int deltaAppend (Task& task)
|
int deltaAppend (Task& task)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
if (context.task.has ("description"))
|
if (context.task.has ("description"))
|
||||||
{
|
{
|
||||||
task.set ("description",
|
task.set ("description",
|
||||||
task.get ("description") + " " + context.task.get ("description"));
|
task.get ("description") + " " + context.task.get ("description"));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
int deltaPrepend (Task& task)
|
int deltaPrepend (Task& task)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
if (context.task.has ("description"))
|
if (context.task.has ("description"))
|
||||||
{
|
{
|
||||||
task.set ("description",
|
task.set ("description",
|
||||||
context.task.get ("description") + " " + task.get ("description"));
|
context.task.get ("description") + " " + task.get ("description"));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -247,11 +251,13 @@ int deltaPrepend (Task& task)
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
int deltaDescription (Task& task)
|
int deltaDescription (Task& task)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
if (context.task.has ("description"))
|
if (context.task.has ("description"))
|
||||||
{
|
{
|
||||||
task.set ("description", context.task.get ("description"));
|
task.set ("description", context.task.get ("description"));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -261,6 +267,7 @@ int deltaTags (Task& task)
|
|||||||
{
|
{
|
||||||
int changes = 0;
|
int changes = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
// Apply or remove tags, if any.
|
// Apply or remove tags, if any.
|
||||||
std::vector <std::string> tags;
|
std::vector <std::string> tags;
|
||||||
context.task.getTags (tags);
|
context.task.getTags (tags);
|
||||||
@@ -276,6 +283,7 @@ int deltaTags (Task& task)
|
|||||||
task.removeTag (*tag);
|
task.removeTag (*tag);
|
||||||
++changes;
|
++changes;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
return changes;
|
return changes;
|
||||||
}
|
}
|
||||||
@@ -285,6 +293,7 @@ int deltaAttributes (Task& task)
|
|||||||
{
|
{
|
||||||
int changes = 0;
|
int changes = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
std::map <std::string, Att>::iterator att;
|
std::map <std::string, Att>::iterator att;
|
||||||
for (att = context.task.begin (); att != context.task.end (); ++att)
|
for (att = context.task.begin (); att != context.task.end (); ++att)
|
||||||
{
|
{
|
||||||
@@ -341,6 +350,7 @@ int deltaAttributes (Task& task)
|
|||||||
++changes;
|
++changes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
return changes;
|
return changes;
|
||||||
}
|
}
|
||||||
@@ -348,16 +358,147 @@ int deltaAttributes (Task& task)
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
int deltaSubstitutions (Task& task)
|
int deltaSubstitutions (Task& task)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
std::string description = task.get ("description");
|
std::string description = task.get ("description");
|
||||||
std::vector <Att> annotations;
|
std::vector <Att> annotations;
|
||||||
task.getAnnotations (annotations);
|
task.getAnnotations (annotations);
|
||||||
|
|
||||||
context.subst.apply (description, annotations);
|
apply_subst (description, annotations);
|
||||||
|
|
||||||
task.set ("description", description);
|
task.set ("description", description);
|
||||||
task.setAnnotations (annotations);
|
task.setAnnotations (annotations);
|
||||||
|
*/
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/*
|
||||||
|
void apply_subst (
|
||||||
|
std::string& description,
|
||||||
|
std::vector <Att>& annotations) const
|
||||||
|
{
|
||||||
|
std::string::size_type pattern;
|
||||||
|
bool sensitive = context.config.getBoolean ("search.case.sensitive");
|
||||||
|
|
||||||
|
if (mFrom != "")
|
||||||
|
{
|
||||||
|
#ifdef FEATURE_REGEX
|
||||||
|
if (context.config.getBoolean ("regex"))
|
||||||
|
{
|
||||||
|
// Insert capturing parentheses, if necessary.
|
||||||
|
std::string pattern;
|
||||||
|
if (mFrom.find ('(') != std::string::npos)
|
||||||
|
pattern = mFrom;
|
||||||
|
else
|
||||||
|
pattern = "(" + mFrom + ")";
|
||||||
|
|
||||||
|
std::vector <int> start;
|
||||||
|
std::vector <int> end;
|
||||||
|
|
||||||
|
// Perform all subs on description.
|
||||||
|
int counter = 0;
|
||||||
|
if (regexMatch (start, end, description, pattern, sensitive))
|
||||||
|
{
|
||||||
|
for (unsigned int i = 0; i < start.size (); ++i)
|
||||||
|
{
|
||||||
|
description.replace (start[i], end[i] - start[i], mTo);
|
||||||
|
if (!mGlobal)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (++counter > 1000)
|
||||||
|
throw ("Terminated substitution because more than a thousand changes were made - infinite loop protection.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Perform all subs on annotations.
|
||||||
|
counter = 0;
|
||||||
|
std::vector <Att>::iterator i;
|
||||||
|
for (i = annotations.begin (); i != annotations.end (); ++i)
|
||||||
|
{
|
||||||
|
std::string annotation = i->value ();
|
||||||
|
start.clear ();
|
||||||
|
end.clear ();
|
||||||
|
|
||||||
|
if (regexMatch (start, end, annotation, pattern, sensitive))
|
||||||
|
{
|
||||||
|
for (unsigned int match = 0; match < start.size (); ++match)
|
||||||
|
{
|
||||||
|
annotation.replace (start[match], end[match] - start[match], mTo);
|
||||||
|
i->value (annotation);
|
||||||
|
if (!mGlobal)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (++counter > 1000)
|
||||||
|
throw ("Terminated substitution because more than a thousand changes were made - infinite loop protection.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
if (mGlobal)
|
||||||
|
{
|
||||||
|
// Perform all subs on description.
|
||||||
|
int counter = 0;
|
||||||
|
pattern = 0;
|
||||||
|
|
||||||
|
while ((pattern = find (description, mFrom, pattern, sensitive)) != std::string::npos)
|
||||||
|
{
|
||||||
|
description.replace (pattern, mFrom.length (), mTo);
|
||||||
|
pattern += mTo.length ();
|
||||||
|
|
||||||
|
if (++counter > 1000)
|
||||||
|
throw ("Terminated substitution because more than a thousand changes were made - infinite loop protection.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Perform all subs on annotations.
|
||||||
|
counter = 0;
|
||||||
|
std::vector <Att>::iterator i;
|
||||||
|
for (i = annotations.begin (); i != annotations.end (); ++i)
|
||||||
|
{
|
||||||
|
pattern = 0;
|
||||||
|
std::string annotation = i->value ();
|
||||||
|
while ((pattern = find (annotation, mFrom, pattern, sensitive)) != std::string::npos)
|
||||||
|
{
|
||||||
|
annotation.replace (pattern, mFrom.length (), mTo);
|
||||||
|
pattern += mTo.length ();
|
||||||
|
|
||||||
|
i->value (annotation);
|
||||||
|
|
||||||
|
if (++counter > 1000)
|
||||||
|
throw ("Terminated substitution because more than a thousand changes were made - infinite loop protection.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Perform first description substitution.
|
||||||
|
if ((pattern = find (description, mFrom, sensitive)) != std::string::npos)
|
||||||
|
description.replace (pattern, mFrom.length (), mTo);
|
||||||
|
|
||||||
|
// Failing that, perform the first annotation substitution.
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::vector <Att>::iterator i;
|
||||||
|
for (i = annotations.begin (); i != annotations.end (); ++i)
|
||||||
|
{
|
||||||
|
std::string annotation = i->value ();
|
||||||
|
if ((pattern = find (annotation, mFrom, sensitive)) != std::string::npos)
|
||||||
|
{
|
||||||
|
annotation.replace (pattern, mFrom.length (), mTo);
|
||||||
|
i->value (annotation);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#ifdef FEATURE_REGEX
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
Reference in New Issue
Block a user