diff --git a/src/Arguments.cpp b/src/Arguments.cpp index 0e384f2b4..b01e18b63 100644 --- a/src/Arguments.cpp +++ b/src/Arguments.cpp @@ -224,8 +224,7 @@ void Arguments::categorize () //////////////////////////////////////////////////////////////////////////////// void Arguments::rc_override ( std::string& home, - File& rc, - std::string& override) + File& rc) { // Is there an override for rc:? std::vector >::iterator arg; @@ -233,7 +232,6 @@ void Arguments::rc_override ( { if (arg->second == "rc") { - override = arg->first; rc = File (arg->first.substr (3)); 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, // leaving only the plain args. -void Arguments::apply_overrides (std::string& var_overrides) +void Arguments::apply_overrides () { std::vector >::iterator 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.skipN (1)) // : { - n.getUntilEOS (value); // Don't care if it's blank. + n.getUntilEOS (value); // May be blank. context.config.set (name, value); context.footnote ("Configuration override rc." + name + "=" + value); - - // Overrides are retained for potential use by the default command. - var_overrides += " " + arg->first; } else context.footnote ("Problem with override: " + arg->first); diff --git a/src/Arguments.h b/src/Arguments.h index 468fb39a3..ac662df8b 100644 --- a/src/Arguments.h +++ b/src/Arguments.h @@ -45,9 +45,9 @@ public: void categorize (); void append_stdin (); - void rc_override (std::string&, File&, std::string&); + void rc_override (std::string&, File&); void get_data_location (std::string&); - void apply_overrides (std::string&); + void apply_overrides (); void resolve_aliases (); std::vector list (); diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fa827d52b..e66d0fa3b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -25,7 +25,6 @@ set (task_SRCS API.cpp API.h Permission.cpp Permission.h Record.cpp Record.h Sequence.cpp Sequence.h - Subst.cpp Subst.h TDB.cpp TDB.h TDB2.cpp TDB2.h Task.cpp Task.h diff --git a/src/Context.cpp b/src/Context.cpp index 6c6c30fcb..2ad8d2e81 100644 --- a/src/Context.cpp +++ b/src/Context.cpp @@ -48,19 +48,12 @@ Context::Context () , data_dir () , extension_dir () , config () -, filter () -, sequence () -, subst () -, task () , tdb () , tdb2 () -, file_override ("") -, var_overrides ("") , dom () , determine_color_use (true) , use_color (true) , verbosity_legacy (false) -, inShadow (false) , terminal_width (0) , terminal_height (0) { @@ -89,7 +82,7 @@ void Context::initialize (int argc, const char** argv) // Process 'rc:' command line override, and remove the argument from the // 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. config.clear (); @@ -111,7 +104,7 @@ void Context::initialize (int argc, const char** argv) args.resolve_aliases (); // 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. if (color ()) @@ -356,6 +349,7 @@ void Context::shadow () //////////////////////////////////////////////////////////////////////////////// void Context::disallowModification () const { +/* if (task.size () || subst.mFrom != "" || tagAdditions.size () || @@ -363,6 +357,7 @@ void Context::disallowModification () const throw std::string ("The '") // + cmd.command + "' command does not allow further modification of a task."; +*/ } //////////////////////////////////////////////////////////////////////////////// @@ -412,14 +407,6 @@ void Context::loadAliases () aliases[var->substr (6)] = config.get (*var); } -//////////////////////////////////////////////////////////////////////////////// -/* -void Context::parse () -{ - parse (args, cmd, task, sequence, subst, filter); -} -*/ - //////////////////////////////////////////////////////////////////////////////// /* void Context::parse ( @@ -699,23 +686,11 @@ void Context::decomposeSortField ( // be initialized. That makes this method something of a misnomer. So be it. void Context::clear () { -// Config config; - filter.clear (); - sequence.clear (); - subst.clear (); -// task.clear (); - task = Task (); tdb.clear (); // TODO Obsolete // tdb2.clear (); args.clear (); - file_override = ""; - var_overrides = ""; -// cmd.command = ""; // TODO Obsolete - tagAdditions.clear (); - tagRemovals.clear (); clearMessages (); - inShadow = false; } //////////////////////////////////////////////////////////////////////////////// @@ -804,6 +779,7 @@ void Context::autoFilter (Att& a, Filter& f) // Add all the tags in the task to the filter. void Context::autoFilter (Filter& f) { +/* // 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 // 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)); debug ("auto filter: -" + *tag); } +*/ } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/Context.h b/src/Context.h index 162977a32..735e9432e 100644 --- a/src/Context.h +++ b/src/Context.h @@ -33,7 +33,6 @@ #include #include #include -#include #include #include #include @@ -68,11 +67,6 @@ public: void footnote (const std::string&); // Footnote message sink void debug (const std::string&); // Debug message sink void clearMessages (); - -/* - void parse (); - void parse (std::vector &, Cmd&, Task&, Sequence&, Subst&, Filter&); -*/ void clear (); void disallowModification () const; @@ -96,17 +90,23 @@ public: Directory extension_dir; Config config; +/* Filter filter; // TODO Obsolete Sequence sequence; // TODO Obsolete Subst subst; // TODO Obsolete Task task; // TODO Obsolete +*/ TDB tdb; // TODO Obsolete TDB2 tdb2; +/* std::string file_override; std::string var_overrides; +*/ std::map aliases; +/* std::vector tagAdditions; // TODO Obsolete std::vector tagRemovals; // TODO Obsolete +*/ Hooks hooks; DOM dom; @@ -119,7 +119,9 @@ public: std::vector headers; std::vector footnotes; std::vector debugMessages; +/* bool inShadow; +*/ std::map commands; diff --git a/src/Subst.cpp b/src/Subst.cpp deleted file mode 100644 index f9b94c91b..000000000 --- a/src/Subst.cpp +++ /dev/null @@ -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 -#include -#include -#include -#include -#include -#include -#include - -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 & 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 start; - std::vector 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 ::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 ::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 ::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; -} - -//////////////////////////////////////////////////////////////////////////////// diff --git a/src/Subst.h b/src/Subst.h deleted file mode 100644 index 28d5800fd..000000000 --- a/src/Subst.h +++ /dev/null @@ -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 -#include - -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 &) const; - void clear (); - -public: - std::string mFrom; - std::string mTo; - bool mGlobal; -}; - -#endif -//////////////////////////////////////////////////////////////////////////////// diff --git a/src/Task.h b/src/Task.h index 67ca87e50..eb45ccf7f 100644 --- a/src/Task.h +++ b/src/Task.h @@ -30,7 +30,6 @@ #include #include -#include #include class Task : public Record diff --git a/src/commands/CmdAdd.cpp b/src/commands/CmdAdd.cpp index 6fb99b9ac..412241479 100644 --- a/src/commands/CmdAdd.cpp +++ b/src/commands/CmdAdd.cpp @@ -49,6 +49,7 @@ CmdAdd::CmdAdd () int CmdAdd::execute (std::string& output) { int rc = 0; +/* std::stringstream out; context.task.set ("uuid", uuid ()); @@ -141,6 +142,7 @@ int CmdAdd::execute (std::string& output) context.tdb.unlock (); output = out.str (); +*/ return rc; } diff --git a/src/commands/CmdAnnotate.cpp b/src/commands/CmdAnnotate.cpp index 558727bc2..4c4412db4 100644 --- a/src/commands/CmdAnnotate.cpp +++ b/src/commands/CmdAnnotate.cpp @@ -48,6 +48,7 @@ int CmdAnnotate::execute (std::string& output) { int rc = 0; +/* if (!context.task.has ("description")) throw std::string ("Cannot apply a blank annotation."); @@ -102,6 +103,7 @@ int CmdAnnotate::execute (std::string& output) context.tdb.unlock (); output = out.str (); +*/ return rc; } diff --git a/src/commands/CmdAppend.cpp b/src/commands/CmdAppend.cpp index 53fb0ef0f..c09d607c4 100644 --- a/src/commands/CmdAppend.cpp +++ b/src/commands/CmdAppend.cpp @@ -46,10 +46,13 @@ CmdAppend::CmdAppend () //////////////////////////////////////////////////////////////////////////////// int CmdAppend::execute (std::string& output) { +/* if (!context.task.has ("description")) throw std::string ("Additional text must be provided."); +*/ int rc = 0; +/* int count = 0; std::stringstream out; @@ -126,6 +129,7 @@ int CmdAppend::execute (std::string& output) out << "Appended " << count << " task" << (count == 1 ? ".\n" : "s.\n"); output = out.str (); +*/ return rc; } diff --git a/src/commands/CmdBurndown.cpp b/src/commands/CmdBurndown.cpp index 58c80617c..093a9dcf3 100644 --- a/src/commands/CmdBurndown.cpp +++ b/src/commands/CmdBurndown.cpp @@ -982,6 +982,7 @@ int CmdBurndownMonthly::execute (std::string& output) { int rc = 0; +/* // Scan the pending tasks, applying any filter. std::vector tasks; context.tdb.lock (context.config.getBoolean ("locking")); @@ -1017,6 +1018,7 @@ int CmdBurndownMonthly::execute (std::string& output) chart.scan (tasks); output = chart.render (); +*/ return rc; } @@ -1035,6 +1037,7 @@ int CmdBurndownWeekly::execute (std::string& output) { int rc = 0; +/* // Scan the pending tasks, applying any filter. std::vector tasks; context.tdb.lock (context.config.getBoolean ("locking")); @@ -1070,6 +1073,7 @@ int CmdBurndownWeekly::execute (std::string& output) chart.scan (tasks); output = chart.render (); +*/ return rc; } @@ -1088,6 +1092,7 @@ int CmdBurndownDaily::execute (std::string& output) { int rc = 0; +/* // Scan the pending tasks, applying any filter. std::vector tasks; context.tdb.lock (context.config.getBoolean ("locking")); @@ -1123,6 +1128,7 @@ int CmdBurndownDaily::execute (std::string& output) chart.scan (tasks); output = chart.render (); +*/ return rc; } diff --git a/src/commands/CmdCalendar.cpp b/src/commands/CmdCalendar.cpp index 1b416edb2..503808bb4 100644 --- a/src/commands/CmdCalendar.cpp +++ b/src/commands/CmdCalendar.cpp @@ -52,6 +52,7 @@ int CmdCalendar::execute (std::string& output) { int rc = 0; +/* // Each month requires 28 text columns width. See how many will actually // fit. But if a preference is specified, and it fits, use it. int width = context.getWidth (); @@ -401,6 +402,7 @@ int CmdCalendar::execute (std::string& output) } output = out.str (); +*/ return rc; } diff --git a/src/commands/CmdColor.cpp b/src/commands/CmdColor.cpp index 9111eac0c..7f5b6bc55 100644 --- a/src/commands/CmdColor.cpp +++ b/src/commands/CmdColor.cpp @@ -47,6 +47,7 @@ CmdColor::CmdColor () int CmdColor::execute (std::string& output) { int rc = 0; +/* std::stringstream out; if (context.color ()) @@ -239,6 +240,7 @@ int CmdColor::execute (std::string& output) } output = out.str (); +*/ return rc; } diff --git a/src/commands/CmdCount.cpp b/src/commands/CmdCount.cpp index a5e34a6d2..c7cab47b5 100644 --- a/src/commands/CmdCount.cpp +++ b/src/commands/CmdCount.cpp @@ -45,6 +45,7 @@ CmdCount::CmdCount () //////////////////////////////////////////////////////////////////////////////// int CmdCount::execute (std::string& output) { +/* // Scan the pending tasks, applying any filter. std::vector tasks; context.tdb.lock (context.config.getBoolean ("locking")); @@ -63,6 +64,7 @@ int CmdCount::execute (std::string& output) std::stringstream out; out << count << "\n"; output = out.str (); +*/ return 0; } diff --git a/src/commands/CmdCustom.cpp b/src/commands/CmdCustom.cpp index f78ac1749..a7788237d 100644 --- a/src/commands/CmdCustom.cpp +++ b/src/commands/CmdCustom.cpp @@ -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. // This is an integer specified as a filter (limit:10). +/* if (context.task.has ("limit")) { if (context.task.get ("limit") == "page") @@ -337,6 +338,7 @@ void CmdCustom::getLimits (const std::string& report, int& rows, int& lines) lines = 0; } } +*/ } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/commands/CmdDelete.cpp b/src/commands/CmdDelete.cpp index 8f132c2a5..1c066318c 100644 --- a/src/commands/CmdDelete.cpp +++ b/src/commands/CmdDelete.cpp @@ -48,6 +48,7 @@ CmdDelete::CmdDelete () int CmdDelete::execute (std::string& output) { int rc = 0; +/* std::stringstream out; context.disallowModification (); @@ -184,6 +185,7 @@ int CmdDelete::execute (std::string& output) context.tdb.unlock (); output = out.str (); +*/ return rc; } diff --git a/src/commands/CmdDenotate.cpp b/src/commands/CmdDenotate.cpp index 07bd7dc78..aca0fa2ae 100644 --- a/src/commands/CmdDenotate.cpp +++ b/src/commands/CmdDenotate.cpp @@ -49,6 +49,7 @@ int CmdDenotate::execute (std::string& output) { int rc = 0; +/* if (!context.task.has ("description")) throw std::string ("Description needed to delete an annotation."); @@ -141,6 +142,7 @@ int CmdDenotate::execute (std::string& output) context.tdb.unlock (); output = out.str (); +*/ return rc; } diff --git a/src/commands/CmdDone.cpp b/src/commands/CmdDone.cpp index df999c846..765753388 100644 --- a/src/commands/CmdDone.cpp +++ b/src/commands/CmdDone.cpp @@ -47,6 +47,7 @@ CmdDone::CmdDone () int CmdDone::execute (std::string& output) { int rc = 0; +/* int count = 0; std::stringstream out; @@ -149,6 +150,7 @@ int CmdDone::execute (std::string& output) << " as done.\n"; output = out.str (); +*/ return rc; } diff --git a/src/commands/CmdDuplicate.cpp b/src/commands/CmdDuplicate.cpp index b05539c94..78a09ec00 100644 --- a/src/commands/CmdDuplicate.cpp +++ b/src/commands/CmdDuplicate.cpp @@ -48,6 +48,7 @@ CmdDuplicate::CmdDuplicate () int CmdDuplicate::execute (std::string& output) { int rc = 0; +/* std::stringstream out; int count = 0; @@ -135,6 +136,7 @@ int CmdDuplicate::execute (std::string& output) context.tdb.unlock (); output = out.str (); +*/ return rc; } diff --git a/src/commands/CmdEdit.cpp b/src/commands/CmdEdit.cpp index 5b5f725aa..99177f110 100644 --- a/src/commands/CmdEdit.cpp +++ b/src/commands/CmdEdit.cpp @@ -56,6 +56,7 @@ int CmdEdit::execute (std::string& output) { int rc = 0; +/* std::stringstream out; std::vector tasks; @@ -77,6 +78,7 @@ int CmdEdit::execute (std::string& output) context.tdb.unlock (); output = out.str (); +*/ return rc; } diff --git a/src/commands/CmdHistory.cpp b/src/commands/CmdHistory.cpp index bfbfa9050..6c4d1b29b 100644 --- a/src/commands/CmdHistory.cpp +++ b/src/commands/CmdHistory.cpp @@ -48,6 +48,7 @@ CmdHistoryMonthly::CmdHistoryMonthly () int CmdHistoryMonthly::execute (std::string& output) { int rc = 0; +/* std::map groups; // Represents any month with data std::map addedGroup; // Additions by month std::map completedGroup; // Completions by month @@ -187,6 +188,7 @@ int CmdHistoryMonthly::execute (std::string& output) } output = out.str (); +*/ return rc; } @@ -204,6 +206,7 @@ CmdHistoryAnnual::CmdHistoryAnnual () int CmdHistoryAnnual::execute (std::string& output) { int rc = 0; +/* std::map groups; // Represents any month with data std::map addedGroup; // Additions by month std::map completedGroup; // Completions by month @@ -340,6 +343,7 @@ int CmdHistoryAnnual::execute (std::string& output) } output = out.str (); +*/ return rc; } @@ -357,6 +361,7 @@ CmdGHistoryMonthly::CmdGHistoryMonthly () int CmdGHistoryMonthly::execute (std::string& output) { int rc = 0; +/* std::map groups; // Represents any month with data std::map addedGroup; // Additions by month std::map completedGroup; // Completions by month @@ -536,6 +541,7 @@ int CmdGHistoryMonthly::execute (std::string& output) } output = out.str (); +*/ return rc; } @@ -553,6 +559,7 @@ CmdGHistoryAnnual::CmdGHistoryAnnual () int CmdGHistoryAnnual::execute (std::string& output) { int rc = 0; +/* std::map groups; // Represents any month with data std::map addedGroup; // Additions by month std::map completedGroup; // Completions by month @@ -729,6 +736,7 @@ int CmdGHistoryAnnual::execute (std::string& output) } output = out.str (); +*/ return rc; } diff --git a/src/commands/CmdIDs.cpp b/src/commands/CmdIDs.cpp index 08e00dff9..cc1a03902 100644 --- a/src/commands/CmdIDs.cpp +++ b/src/commands/CmdIDs.cpp @@ -47,6 +47,7 @@ CmdIDs::CmdIDs () //////////////////////////////////////////////////////////////////////////////// int CmdIDs::execute (std::string& output) { +/* // Scan the pending tasks, applying any filter. std::vector tasks; context.tdb.lock (context.config.getBoolean ("locking")); @@ -64,6 +65,7 @@ int CmdIDs::execute (std::string& output) std::sort (ids.begin (), ids.end ()); output = compressIds (ids) + "\n"; +*/ return 0; } diff --git a/src/commands/CmdImport.cpp b/src/commands/CmdImport.cpp index f332c6a12..12b218ce2 100644 --- a/src/commands/CmdImport.cpp +++ b/src/commands/CmdImport.cpp @@ -1287,6 +1287,7 @@ std::string CmdImport::YAML (const std::vector & lines) int CmdImport::execute (std::string& output) { int rc = 0; +/* std::stringstream out; // 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_yaml: out << YAML (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 != "") @@ -1369,6 +1370,7 @@ int CmdImport::execute (std::string& output) throw std::string ("You must specify a file to import."); output = out.str (); +*/ return rc; } diff --git a/src/commands/CmdInfo.cpp b/src/commands/CmdInfo.cpp index 00de8b311..33adbef1a 100644 --- a/src/commands/CmdInfo.cpp +++ b/src/commands/CmdInfo.cpp @@ -51,6 +51,7 @@ int CmdInfo::execute (std::string& output) { int rc = 0; +/* // Get all the tasks. std::vector tasks; context.tdb.lock (context.config.getBoolean ("locking")); @@ -397,6 +398,7 @@ int CmdInfo::execute (std::string& output) } output = out.str (); +*/ return rc; } diff --git a/src/commands/CmdLog.cpp b/src/commands/CmdLog.cpp index 9c696e7e6..dbd93d1f0 100644 --- a/src/commands/CmdLog.cpp +++ b/src/commands/CmdLog.cpp @@ -48,6 +48,7 @@ CmdLog::CmdLog () int CmdLog::execute (std::string& output) { int rc = 0; +/* std::stringstream out; context.task.setStatus (Task::completed); @@ -109,6 +110,7 @@ int CmdLog::execute (std::string& output) context.tdb.unlock (); output = out.str (); +*/ return rc; } diff --git a/src/commands/CmdMerge.cpp b/src/commands/CmdMerge.cpp index 1b1b4f574..de286557f 100644 --- a/src/commands/CmdMerge.cpp +++ b/src/commands/CmdMerge.cpp @@ -49,6 +49,7 @@ CmdMerge::CmdMerge () //////////////////////////////////////////////////////////////////////////////// int CmdMerge::execute (std::string& output) { +/* std::string file = trim (context.task.get ("description")); std::string pushfile = ""; 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 " "the uri of a remote .task directory, or create a " "'merge.default.uri' entry in your .taskrc file."); +*/ return 0; } diff --git a/src/commands/CmdModify.cpp b/src/commands/CmdModify.cpp index 6d379e926..11c11512e 100644 --- a/src/commands/CmdModify.cpp +++ b/src/commands/CmdModify.cpp @@ -51,6 +51,7 @@ CmdModify::CmdModify () int CmdModify::execute (std::string& output) { int count = 0; +/* std::stringstream out; std::vector tasks; @@ -181,6 +182,7 @@ int CmdModify::execute (std::string& output) out << "Modified " << count << " task" << (count == 1 ? ".\n" : "s.\n"); output = out.str (); +*/ return 0; } diff --git a/src/commands/CmdPrepend.cpp b/src/commands/CmdPrepend.cpp index 872f3279a..06b8301c8 100644 --- a/src/commands/CmdPrepend.cpp +++ b/src/commands/CmdPrepend.cpp @@ -46,10 +46,13 @@ CmdPrepend::CmdPrepend () //////////////////////////////////////////////////////////////////////////////// int CmdPrepend::execute (std::string& output) { +/* if (!context.task.has ("description")) throw std::string ("Additional text must be provided."); +*/ int rc = 0; +/* int count = 0; std::stringstream out; @@ -126,6 +129,7 @@ int CmdPrepend::execute (std::string& output) out << "Prepended " << count << " task" << (count == 1 ? ".\n" : "s.\n"); output = out.str (); +*/ return rc; } diff --git a/src/commands/CmdProjects.cpp b/src/commands/CmdProjects.cpp index 35a3e9b73..032fddc78 100644 --- a/src/commands/CmdProjects.cpp +++ b/src/commands/CmdProjects.cpp @@ -47,6 +47,7 @@ CmdProjects::CmdProjects () int CmdProjects::execute (std::string& output) { int rc = 0; +/* std::stringstream out; std::vector tasks; @@ -128,6 +129,7 @@ int CmdProjects::execute (std::string& output) } output = out.str (); +*/ return rc; } @@ -144,6 +146,7 @@ CmdCompletionProjects::CmdCompletionProjects () //////////////////////////////////////////////////////////////////////////////// int CmdCompletionProjects::execute (std::string& output) { +/* std::vector tasks; 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) if (project->first.length ()) output += project->first + "\n"; +*/ return 0; } diff --git a/src/commands/CmdPull.cpp b/src/commands/CmdPull.cpp index c9b94a08c..c2c5689f5 100644 --- a/src/commands/CmdPull.cpp +++ b/src/commands/CmdPull.cpp @@ -48,6 +48,7 @@ CmdPull::CmdPull () //////////////////////////////////////////////////////////////////////////////// int CmdPull::execute (std::string& output) { +/* std::string file = trim (context.task.get ("description")); 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 " "the uri of a remote .task directory, or create a " "'pull.default.uri' entry in your .taskrc file."); +*/ return 0; } diff --git a/src/commands/CmdPush.cpp b/src/commands/CmdPush.cpp index addff1627..9d9ec2ae8 100644 --- a/src/commands/CmdPush.cpp +++ b/src/commands/CmdPush.cpp @@ -50,6 +50,7 @@ CmdPush::CmdPush () // this is potentially on another machine, no checking can be performed. int CmdPush::execute (std::string& output) { +/* std::string file = trim (context.task.get ("description")); 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 " "the uri of a remote .task directory, or create a " "'push.default.uri' entry in your .taskrc file."); +*/ return 0; } diff --git a/src/commands/CmdQuery.cpp b/src/commands/CmdQuery.cpp index 24d87ae4f..1d8d1d4cf 100644 --- a/src/commands/CmdQuery.cpp +++ b/src/commands/CmdQuery.cpp @@ -46,6 +46,7 @@ int CmdQuery::execute (std::string& output) { int rc = 0; +/* // Get all the tasks. std::vector tasks; context.tdb.lock (context.config.getBoolean ("locking")); @@ -77,6 +78,7 @@ int CmdQuery::execute (std::string& output) } output += "\n"; +*/ return rc; } diff --git a/src/commands/CmdShell.cpp b/src/commands/CmdShell.cpp index adb6ee203..21bd1779a 100644 --- a/src/commands/CmdShell.cpp +++ b/src/commands/CmdShell.cpp @@ -47,6 +47,7 @@ CmdShell::CmdShell () //////////////////////////////////////////////////////////////////////////////// int CmdShell::execute (std::string&) { +/* // Display some kind of welcome message. Color bold (Color::nocolor, Color::nocolor, false, true, false); std::cout << (context.color () ? bold.colorize (PACKAGE_STRING) : PACKAGE_STRING) @@ -85,17 +86,15 @@ int CmdShell::execute (std::string&) { try { -/* - context.clear (); - std::vector args; - split (args, decoratedCommand, ' '); - std::vector ::iterator arg; - for (arg = args.begin (); arg != args.end (); ++arg) - context.args.push_back (*arg); - - context.initialize (0, NULL); - context.run (); -*/ +// context.clear (); +// std::vector args; +// split (args, decoratedCommand, ' '); +// std::vector ::iterator arg; +// for (arg = args.begin (); arg != args.end (); ++arg) +// context.args.push_back (*arg); +// +// context.initialize (0, NULL); +// context.run (); } catch (std::string& error) @@ -113,6 +112,7 @@ int CmdShell::execute (std::string&) // No need to repeat any overrides after the shell quits. context.clearMessages (); +*/ return 0; } diff --git a/src/commands/CmdStart.cpp b/src/commands/CmdStart.cpp index 9149c8bd5..6c9df28bf 100644 --- a/src/commands/CmdStart.cpp +++ b/src/commands/CmdStart.cpp @@ -46,6 +46,7 @@ CmdStart::CmdStart () int CmdStart::execute (std::string& output) { int rc = 0; +/* std::stringstream out; context.disallowModification (); @@ -105,6 +106,7 @@ int CmdStart::execute (std::string& output) context.tdb.unlock (); output = out.str (); +*/ return rc; } diff --git a/src/commands/CmdStatistics.cpp b/src/commands/CmdStatistics.cpp index c92a1cd0d..000b9bb9b 100644 --- a/src/commands/CmdStatistics.cpp +++ b/src/commands/CmdStatistics.cpp @@ -52,6 +52,7 @@ CmdStatistics::CmdStatistics () int CmdStatistics::execute (std::string& output) { int rc = 0; +/* std::stringstream out; // Go get the file sizes. @@ -273,6 +274,7 @@ int CmdStatistics::execute (std::string& output) << optionalBlankLine (); output = out.str (); +*/ return rc; } diff --git a/src/commands/CmdStop.cpp b/src/commands/CmdStop.cpp index 86493a81c..219184dde 100644 --- a/src/commands/CmdStop.cpp +++ b/src/commands/CmdStop.cpp @@ -46,6 +46,7 @@ CmdStop::CmdStop () int CmdStop::execute (std::string& output) { int rc = 0; +/* std::stringstream out; context.disallowModification (); @@ -97,6 +98,7 @@ int CmdStop::execute (std::string& output) context.tdb.unlock (); output = out.str (); +*/ return rc; } diff --git a/src/commands/CmdSummary.cpp b/src/commands/CmdSummary.cpp index 0b21b01f1..b7b4d7577 100644 --- a/src/commands/CmdSummary.cpp +++ b/src/commands/CmdSummary.cpp @@ -54,6 +54,7 @@ int CmdSummary::execute (std::string& output) { int rc = 0; +/* // Scan the pending tasks. std::vector tasks; context.tdb.lock (context.config.getBoolean ("locking")); @@ -175,6 +176,7 @@ int CmdSummary::execute (std::string& output) } output = out.str (); +*/ return rc; } diff --git a/src/commands/CmdTags.cpp b/src/commands/CmdTags.cpp index c9096545f..37b022b71 100644 --- a/src/commands/CmdTags.cpp +++ b/src/commands/CmdTags.cpp @@ -49,6 +49,7 @@ CmdTags::CmdTags () int CmdTags::execute (std::string& output) { int rc = 0; +/* std::stringstream out; std::vector tasks; @@ -117,6 +118,7 @@ int CmdTags::execute (std::string& output) } output = out.str (); +*/ return rc; } @@ -133,6 +135,7 @@ CmdCompletionTags::CmdCompletionTags () //////////////////////////////////////////////////////////////////////////////// int CmdCompletionTags::execute (std::string& output) { +/* std::vector tasks; context.tdb.lock (context.config.getBoolean ("locking")); @@ -173,6 +176,7 @@ int CmdCompletionTags::execute (std::string& output) out << it->first << "\n"; output = out.str (); +*/ return 0; } diff --git a/src/commands/CmdTimesheet.cpp b/src/commands/CmdTimesheet.cpp index 0e887f6f4..b5165d050 100644 --- a/src/commands/CmdTimesheet.cpp +++ b/src/commands/CmdTimesheet.cpp @@ -50,6 +50,7 @@ int CmdTimesheet::execute (std::string& output) { int rc = 0; +/* // Scan the pending tasks. std::vector tasks; context.tdb.lock (context.config.getBoolean ("locking")); @@ -179,6 +180,7 @@ int CmdTimesheet::execute (std::string& output) } output = out.str (); +*/ return rc; } diff --git a/src/commands/CmdUrgency.cpp b/src/commands/CmdUrgency.cpp index 3bcb0d196..a7a41e9e8 100644 --- a/src/commands/CmdUrgency.cpp +++ b/src/commands/CmdUrgency.cpp @@ -46,6 +46,7 @@ CmdUrgency::CmdUrgency () //////////////////////////////////////////////////////////////////////////////// int CmdUrgency::execute (std::string& output) { +/* // Get all the tasks. std::vector tasks; context.tdb.lock (context.config.getBoolean ("locking")); @@ -73,6 +74,7 @@ int CmdUrgency::execute (std::string& output) << "\n"; output = out.str (); +*/ return 0; } diff --git a/src/helpers.cpp b/src/helpers.cpp index 57f06db7b..55383b3db 100644 --- a/src/helpers.cpp +++ b/src/helpers.cpp @@ -197,21 +197,22 @@ static void countTasks ( break; } } + if (skip == 0) { switch (it->getStatus ()) { - case Task::pending: - case Task::waiting: - ++count_pending; - break; + case Task::pending: + case Task::waiting: + ++count_pending; + break; - case Task::completed: - ++count_done; - break; + case Task::completed: + ++count_done; + break; - default: - break; + default: + break; } } } @@ -221,25 +222,28 @@ static void countTasks ( //////////////////////////////////////////////////////////////////////////////// int deltaAppend (Task& task) { +/* if (context.task.has ("description")) { task.set ("description", task.get ("description") + " " + context.task.get ("description")); return 1; } - +*/ return 0; } //////////////////////////////////////////////////////////////////////////////// int deltaPrepend (Task& task) { +/* if (context.task.has ("description")) { task.set ("description", context.task.get ("description") + " " + task.get ("description")); return 1; } +*/ return 0; } @@ -247,11 +251,13 @@ int deltaPrepend (Task& task) //////////////////////////////////////////////////////////////////////////////// int deltaDescription (Task& task) { +/* if (context.task.has ("description")) { task.set ("description", context.task.get ("description")); return 1; } +*/ return 0; } @@ -261,6 +267,7 @@ int deltaTags (Task& task) { int changes = 0; +/* // Apply or remove tags, if any. std::vector tags; context.task.getTags (tags); @@ -276,6 +283,7 @@ int deltaTags (Task& task) task.removeTag (*tag); ++changes; } +*/ return changes; } @@ -285,6 +293,7 @@ int deltaAttributes (Task& task) { int changes = 0; +/* std::map ::iterator att; for (att = context.task.begin (); att != context.task.end (); ++att) { @@ -341,6 +350,7 @@ int deltaAttributes (Task& task) ++changes; } } +*/ return changes; } @@ -348,16 +358,147 @@ int deltaAttributes (Task& task) //////////////////////////////////////////////////////////////////////////////// int deltaSubstitutions (Task& task) { +/* std::string description = task.get ("description"); std::vector annotations; task.getAnnotations (annotations); - context.subst.apply (description, annotations); + apply_subst (description, annotations); task.set ("description", description); task.setAnnotations (annotations); +*/ return 1; } //////////////////////////////////////////////////////////////////////////////// +/* +void apply_subst ( + std::string& description, + std::vector & 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 start; + std::vector 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 ::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 ::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 ::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 + } +} +*/ + +////////////////////////////////////////////////////////////////////////////////