Enhancement - usage and help commands

- Implemented usage and help commands.
This commit is contained in:
Paul Beckingham 2009-06-10 00:18:02 -04:00
parent 0449f9e0a2
commit 8dfe4bd30a
3 changed files with 7 additions and 7 deletions

View file

@ -164,6 +164,7 @@ void Context::dispatch ()
else if (cmd.command == "tags") { out = handleTags (); } else if (cmd.command == "tags") { out = handleTags (); }
else if (cmd.command == "colors") { out = handleColor (); } else if (cmd.command == "colors") { out = handleColor (); }
else if (cmd.command == "version") { out = handleVersion (); } else if (cmd.command == "version") { out = handleVersion (); }
else if (cmd.command == "help") { out = longUsage (); }
/* /*
else if (command == "info") { out = handleInfo (); } else if (command == "info") { out = handleInfo (); }
else if (command == "stats") { out = handleReportStats (); } else if (command == "stats") { out = handleReportStats (); }
@ -172,7 +173,6 @@ void Context::dispatch ()
else if (command == "calendar") { out = handleReportCalendar (); } else if (command == "calendar") { out = handleReportCalendar (); }
else if (command == "summary") { out = handleReportSummary (); } else if (command == "summary") { out = handleReportSummary (); }
else if (command == "timesheet") { out = handleReportTimesheet (); } else if (command == "timesheet") { out = handleReportTimesheet (); }
else if (command == "help") { out = longUsage (); }
// Commands that cause updates. // Commands that cause updates.
else if (command == "" && task.getId ()) { cmdMod = true; out = handleModify (); } else if (command == "" && task.getId ()) { cmdMod = true; out = handleModify (); }
@ -197,8 +197,10 @@ void Context::dispatch ()
else if (isCustomReport (command)) { if (gc) gcMod = tdb.gc (); out = handleCustomReport (command); } else if (isCustomReport (command)) { if (gc) gcMod = tdb.gc (); out = handleCustomReport (command); }
// If the command is not recognized, display usage. // If the command is not recognized, display usage.
*/
else { out = shortUsage (); } else { out = shortUsage (); }
/*
// Only update the shadow file if such an update was not suppressed (shadow), // Only update the shadow file if such an update was not suppressed (shadow),
// and if an actual change occurred (gcMod || cmdMod). // and if an actual change occurred (gcMod || cmdMod).
if (shadow && (gcMod || cmdMod)) if (shadow && (gcMod || cmdMod))

View file

@ -54,7 +54,7 @@
Context context; Context context;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
static std::string shortUsage () std::string shortUsage ()
{ {
std::stringstream out; std::stringstream out;
Table table; Table table;
@ -241,7 +241,7 @@ static std::string shortUsage ()
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
static std::string longUsage () std::string longUsage ()
{ {
std::stringstream out; std::stringstream out;
out << shortUsage () out << shortUsage ()
@ -462,7 +462,6 @@ std::string runTaskCommand (
else if (command == "calendar") { out = handleReportCalendar (tdb, task); } else if (command == "calendar") { out = handleReportCalendar (tdb, task); }
else if (command == "summary") { out = handleReportSummary (tdb, task); } else if (command == "summary") { out = handleReportSummary (tdb, task); }
else if (command == "timesheet") { out = handleReportTimesheet (tdb, task); } else if (command == "timesheet") { out = handleReportTimesheet (tdb, task); }
else if (command == "help") { out = longUsage ( ); }
// Commands that cause updates. // Commands that cause updates.
else if (command == "" && task.getId ()) { cmdMod = true; out = handleModify (tdb, task); } else if (command == "" && task.getId ()) { cmdMod = true; out = handleModify (tdb, task); }
@ -486,9 +485,6 @@ std::string runTaskCommand (
else if (command == "overdue") { if (gc) gcMod = tdb.gc (); out = handleReportOverdue (tdb, task); } else if (command == "overdue") { if (gc) gcMod = tdb.gc (); out = handleReportOverdue (tdb, task); }
else if (isCustomReport (command)) { if (gc) gcMod = tdb.gc (); out = handleCustomReport (tdb, task, command); } else if (isCustomReport (command)) { if (gc) gcMod = tdb.gc (); out = handleCustomReport (tdb, task, command); }
// If the command is not recognized, display usage.
else { out = shortUsage (); }
// Only update the shadow file if such an update was not suppressed (shadow), // Only update the shadow file if such an update was not suppressed (shadow),
// and if an actual change occurred (gcMod || cmdMod). // and if an actual change occurred (gcMod || cmdMod).
if (shadow && (gcMod || cmdMod)) if (shadow && (gcMod || cmdMod))

View file

@ -53,6 +53,8 @@ void gatherNextTasks (const TDB&, T&, std::vector <T>&, std::vector <int>&);
void onChangeCallback (); void onChangeCallback ();
std::string runTaskCommand (int, char**, TDB&, bool gc = true, bool shadow = true); std::string runTaskCommand (int, char**, TDB&, bool gc = true, bool shadow = true);
std::string runTaskCommand (std::vector <std::string>&, TDB&, bool gc = false, bool shadow = false); std::string runTaskCommand (std::vector <std::string>&, TDB&, bool gc = false, bool shadow = false);
std::string shortUsage ();
std::string longUsage ();
// recur.cpp // recur.cpp
void handleRecurrence (); void handleRecurrence ();