From bd7162f58d3d69cfa8490fd0fc2d79a483b9f7ec Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sun, 4 Sep 2016 17:52:01 -0400 Subject: [PATCH] TS-28: Please add a (m)odify feature for review - Thanks to Ian R. Learmonth. --- AUTHORS | 1 + ChangeLog | 2 ++ src/review.cpp | 87 ++++++++++++++++++++++++++++++++++---------------- 3 files changed, 63 insertions(+), 27 deletions(-) diff --git a/AUTHORS b/AUTHORS index 4b8f4bc..b69cd32 100644 --- a/AUTHORS +++ b/AUTHORS @@ -19,3 +19,4 @@ suggestions: jonbobbly hosaka Lars Kumbier + Ian R. Learmonth diff --git a/ChangeLog b/ChangeLog index 585c10a..c96da56 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,8 @@ (thanks to Lars Kumbier). - TS-24 add review option (m)odify (thanks to David Patrick). +- TS-28 Please add a (m)odify feature for review + (thanks to Ian R. Learmonth). - Implemented 'review' command. - Implemented 'diag' command. - Added 'review N' option, to specify the number of tasks you would like to diff --git a/src/review.cpp b/src/review.cpp index 4649fbd..feeb79e 100644 --- a/src/review.cpp +++ b/src/review.cpp @@ -85,6 +85,23 @@ static void editTask (const std::string& uuid) std::cout << "Modified.\n\n\n\n"; } +//////////////////////////////////////////////////////////////////////////////// +static void modifyTask (const std::string& uuid) +{ + Color text ("color15 on gray6"); + std::string modifications; + do + { + modifications = getResponse (text.colorize (" Enter modification args [example: +tag -tag /teh/the/ project:X] ") + " "); + } + while (modifications == ""); + + std::string command = "task rc.confirmation:no rc.verbose:nothing " + uuid + " modify " + modifications; + system (command.c_str ()); + + std::cout << "Modified.\n\n\n\n"; +} + //////////////////////////////////////////////////////////////////////////////// static void reviewTask (const std::string& uuid) { @@ -171,15 +188,20 @@ static const std::string banner ( static const std::string menu () { Color text ("color15 on gray6"); - return text.colorize (" (Enter) Mark as reviewed, (s)kip, (e)dit, (c)ompleted, (d)eleted, (q)uit "); + return text.colorize (" (Enter) Mark as reviewed, (s)kip, (e)dit, (m)odify, (c)ompleted, (d)eleted, (q)uit ") + " "; } //////////////////////////////////////////////////////////////////////////////// static void reviewLoop (const std::vector & uuids, unsigned int limit, bool autoClear) { - unsigned int reviewed = 0; - auto total = std::min (static_cast (uuids.size ()), limit); auto width = getWidth (); + unsigned int reviewed = 0; + + // If a limit was specified ('review 10'), then it should override the data + // set size, if it is smaller. + unsigned int total = uuids.size (); + if (limit) + total = std::min (total, limit); if (total == 0) { @@ -204,33 +226,44 @@ static void reviewLoop (const std::vector & uuids, unsigned int lim dummy, description); - std::cout << banner (current + 1, total, width, Lexer::trimRight (description, "\n")); - - // Use 'system' to run the command and show the output. - std::string command = "task " + uuid + " information"; - system (command.c_str ()); - - // Display prompt, get input. - auto response = getResponse (menu ()); - - if (response == "e") { editTask (uuid); } - else if (response == "s") { std::cout << "Skipped\n\n"; ++current; } - else if (response == "c") { completeTask (uuid); ++current; ++reviewed; } - else if (response == "d") { deleteTask (uuid); ++current; ++reviewed; } - else if (response == "") { reviewTask (uuid); ++current; ++reviewed; } - else if (response == "r") { reviewTask (uuid); ++current; ++reviewed; } - else if (response == "q") { break; } - - else + std::string response; + bool repeat; + do { - std::cout << format ("Command '{1}' is not recognized.", response) << "\n"; + repeat = false; + std::cout << banner (current + 1, total, width, Lexer::trimRight (description, "\n")); + + // Use 'system' to run the command and show the output. + std::string command = "task " + uuid + " information"; + system (command.c_str ()); + + // Display prompt, get input. + response = getResponse (menu ()); + + if (response == "e") { editTask (uuid); } + if (response == "m") { modifyTask (uuid); repeat = true; } + else if (response == "s") { std::cout << "Skipped\n\n"; ++current; } + else if (response == "c") { completeTask (uuid); ++current; ++reviewed; } + else if (response == "d") { deleteTask (uuid); ++current; ++reviewed; } + else if (response == "") { reviewTask (uuid); ++current; ++reviewed; } + else if (response == "r") { reviewTask (uuid); ++current; ++reviewed; } + else if (response == "q") { break; } + + else + { + std::cout << format ("Command '{1}' is not recognized.", response) << "\n"; + } + + // Note that just hitting yields an empty command, which does + // nothing but advance to the next task. + + if (autoClear) + std::cout << "\033[2J\033[0;0H"; } + while (repeat); - // Note that just hitting yields an empty command, which does - // nothing but advance to the next task. - - if (autoClear) - std::cout << "\033[2J\033[0;0H"; + if (response == "q") + break; } std::cout << "\n"