From 8dfe4bd30a0a5ad799ceb4a4f614f1de4944d540 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Wed, 10 Jun 2009 00:18:02 -0400 Subject: [PATCH] Enhancement - usage and help commands - Implemented usage and help commands. --- src/Context.cpp | 4 +++- src/task.cpp | 8 ++------ src/task.h | 2 ++ 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Context.cpp b/src/Context.cpp index aa6b12c14..2965b3381 100644 --- a/src/Context.cpp +++ b/src/Context.cpp @@ -164,6 +164,7 @@ void Context::dispatch () else if (cmd.command == "tags") { out = handleTags (); } else if (cmd.command == "colors") { out = handleColor (); } else if (cmd.command == "version") { out = handleVersion (); } + else if (cmd.command == "help") { out = longUsage (); } /* else if (command == "info") { out = handleInfo (); } else if (command == "stats") { out = handleReportStats (); } @@ -172,7 +173,6 @@ void Context::dispatch () else if (command == "calendar") { out = handleReportCalendar (); } else if (command == "summary") { out = handleReportSummary (); } else if (command == "timesheet") { out = handleReportTimesheet (); } - else if (command == "help") { out = longUsage (); } // Commands that cause updates. 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); } // If the command is not recognized, display usage. +*/ else { out = shortUsage (); } +/* // Only update the shadow file if such an update was not suppressed (shadow), // and if an actual change occurred (gcMod || cmdMod). if (shadow && (gcMod || cmdMod)) diff --git a/src/task.cpp b/src/task.cpp index 53fb8aee8..a28a89219 100644 --- a/src/task.cpp +++ b/src/task.cpp @@ -54,7 +54,7 @@ Context context; //////////////////////////////////////////////////////////////////////////////// -static std::string shortUsage () +std::string shortUsage () { std::stringstream out; Table table; @@ -241,7 +241,7 @@ static std::string shortUsage () } //////////////////////////////////////////////////////////////////////////////// -static std::string longUsage () +std::string longUsage () { std::stringstream out; out << shortUsage () @@ -462,7 +462,6 @@ std::string runTaskCommand ( else if (command == "calendar") { out = handleReportCalendar (tdb, task); } else if (command == "summary") { out = handleReportSummary (tdb, task); } else if (command == "timesheet") { out = handleReportTimesheet (tdb, task); } - else if (command == "help") { out = longUsage ( ); } // Commands that cause updates. 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 (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), // and if an actual change occurred (gcMod || cmdMod). if (shadow && (gcMod || cmdMod)) diff --git a/src/task.h b/src/task.h index d10dfbf4f..6714603e2 100644 --- a/src/task.h +++ b/src/task.h @@ -53,6 +53,8 @@ void gatherNextTasks (const TDB&, T&, std::vector &, std::vector &); void onChangeCallback (); std::string runTaskCommand (int, char**, TDB&, bool gc = true, bool shadow = true); std::string runTaskCommand (std::vector &, TDB&, bool gc = false, bool shadow = false); +std::string shortUsage (); +std::string longUsage (); // recur.cpp void handleRecurrence ();