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:
Paul Beckingham 2011-06-04 15:11:34 -04:00
parent b4c1e47ab4
commit 58a677ffb5
42 changed files with 265 additions and 383 deletions

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -982,6 +982,7 @@ int CmdBurndownMonthly::execute (std::string& output)
{
int rc = 0;
/*
// Scan the pending tasks, applying any filter.
std::vector <Task> 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 <Task> 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 <Task> 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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -45,6 +45,7 @@ CmdCount::CmdCount ()
////////////////////////////////////////////////////////////////////////////////
int CmdCount::execute (std::string& output)
{
/*
// Scan the pending tasks, applying any filter.
std::vector <Task> 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;
}

View file

@ -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;
}
}
*/
}
////////////////////////////////////////////////////////////////////////////////

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -56,6 +56,7 @@ int CmdEdit::execute (std::string& output)
{
int rc = 0;
/*
std::stringstream out;
std::vector <Task> tasks;
@ -77,6 +78,7 @@ int CmdEdit::execute (std::string& output)
context.tdb.unlock ();
output = out.str ();
*/
return rc;
}

View file

@ -48,6 +48,7 @@ CmdHistoryMonthly::CmdHistoryMonthly ()
int CmdHistoryMonthly::execute (std::string& output)
{
int rc = 0;
/*
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> 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 <time_t, int> groups; // Represents any month with data
std::map <time_t, int> addedGroup; // Additions by month
std::map <time_t, int> 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 <time_t, int> groups; // Represents any month with data
std::map <time_t, int> addedGroup; // Additions by month
std::map <time_t, int> 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 <time_t, int> groups; // Represents any month with data
std::map <time_t, int> addedGroup; // Additions by month
std::map <time_t, int> completedGroup; // Completions by month
@ -729,6 +736,7 @@ int CmdGHistoryAnnual::execute (std::string& output)
}
output = out.str ();
*/
return rc;
}

View file

@ -47,6 +47,7 @@ CmdIDs::CmdIDs ()
////////////////////////////////////////////////////////////////////////////////
int CmdIDs::execute (std::string& output)
{
/*
// Scan the pending tasks, applying any filter.
std::vector <Task> 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;
}

View file

@ -1287,6 +1287,7 @@ std::string CmdImport::YAML (const std::vector <std::string>& 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;
}

View file

@ -51,6 +51,7 @@ int CmdInfo::execute (std::string& output)
{
int rc = 0;
/*
// Get all the tasks.
std::vector <Task> tasks;
context.tdb.lock (context.config.getBoolean ("locking"));
@ -397,6 +398,7 @@ int CmdInfo::execute (std::string& output)
}
output = out.str ();
*/
return rc;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -51,6 +51,7 @@ CmdModify::CmdModify ()
int CmdModify::execute (std::string& output)
{
int count = 0;
/*
std::stringstream out;
std::vector <Task> 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;
}

View file

@ -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;
}

View file

@ -47,6 +47,7 @@ CmdProjects::CmdProjects ()
int CmdProjects::execute (std::string& output)
{
int rc = 0;
/*
std::stringstream out;
std::vector <Task> 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 <Task> 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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -46,6 +46,7 @@ int CmdQuery::execute (std::string& output)
{
int rc = 0;
/*
// Get all the tasks.
std::vector <Task> tasks;
context.tdb.lock (context.config.getBoolean ("locking"));
@ -77,6 +78,7 @@ int CmdQuery::execute (std::string& output)
}
output += "\n";
*/
return rc;
}

View file

@ -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 <std::string> args;
split (args, decoratedCommand, ' ');
std::vector <std::string>::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 <std::string> args;
// split (args, decoratedCommand, ' ');
// std::vector <std::string>::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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -54,6 +54,7 @@ int CmdSummary::execute (std::string& output)
{
int rc = 0;
/*
// Scan the pending tasks.
std::vector <Task> tasks;
context.tdb.lock (context.config.getBoolean ("locking"));
@ -175,6 +176,7 @@ int CmdSummary::execute (std::string& output)
}
output = out.str ();
*/
return rc;
}

View file

@ -49,6 +49,7 @@ CmdTags::CmdTags ()
int CmdTags::execute (std::string& output)
{
int rc = 0;
/*
std::stringstream out;
std::vector <Task> 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 <Task> 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;
}

View file

@ -50,6 +50,7 @@ int CmdTimesheet::execute (std::string& output)
{
int rc = 0;
/*
// Scan the pending tasks.
std::vector <Task> tasks;
context.tdb.lock (context.config.getBoolean ("locking"));
@ -179,6 +180,7 @@ int CmdTimesheet::execute (std::string& output)
}
output = out.str ();
*/
return rc;
}

View file

@ -46,6 +46,7 @@ CmdUrgency::CmdUrgency ()
////////////////////////////////////////////////////////////////////////////////
int CmdUrgency::execute (std::string& output)
{
/*
// Get all the tasks.
std::vector <Task> tasks;
context.tdb.lock (context.config.getBoolean ("locking"));
@ -73,6 +74,7 @@ int CmdUrgency::execute (std::string& output)
<< "\n";
output = out.str ();
*/
return 0;
}