mirror of
https://github.com/GothenburgBitFactory/taskshell.git
synced 2025-07-07 20:06:42 +02:00
Review: Usability/feedback improvements
- Added a full-width colored banner to track progress through the review set. - Added a colored prompt for per-task actions. - Removed debug output.
This commit is contained in:
parent
077dd52787
commit
964d1aa93e
1 changed files with 45 additions and 19 deletions
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
#include <cmake.h>
|
#include <cmake.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <sstream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -42,6 +43,7 @@
|
||||||
#include <sys/termios.h>
|
#include <sys/termios.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <Color.h>
|
||||||
#include <text.h>
|
#include <text.h>
|
||||||
#include <util.h>
|
#include <util.h>
|
||||||
#include <i18n.h>
|
#include <i18n.h>
|
||||||
|
@ -106,44 +108,68 @@ static void deleteTask (const std::string& uuid)
|
||||||
std::cout << STRING_REVIEW_DELETED << "\n";
|
std::cout << STRING_REVIEW_DELETED << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
static const std::string banner (
|
||||||
|
unsigned int current,
|
||||||
|
unsigned int total,
|
||||||
|
unsigned int width,
|
||||||
|
const std::string& message)
|
||||||
|
{
|
||||||
|
std::stringstream out;
|
||||||
|
out << " ["
|
||||||
|
<< current
|
||||||
|
<< " of "
|
||||||
|
<< total
|
||||||
|
<< "] "
|
||||||
|
<< message;
|
||||||
|
|
||||||
|
out << std::string (width - out.str ().length () - 1, ' ');
|
||||||
|
|
||||||
|
Color color ("white on blue");
|
||||||
|
return color.colorize (out.str ()) + "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
static const std::string menu ()
|
||||||
|
{
|
||||||
|
Color text ("white on blue");
|
||||||
|
return text.colorize (" (Enter) Skip, (e)dit, (c)ompleted, (d)eleted, Mark as (r)eviewed, (q)uit ");
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
static void reviewLoop (const std::vector <std::string>& uuids)
|
static void reviewLoop (const std::vector <std::string>& uuids)
|
||||||
{
|
{
|
||||||
auto tasks = 0;
|
auto tasks = 0;
|
||||||
auto total = uuids.size ();
|
auto total = uuids.size ();
|
||||||
|
auto width = getWidth ();
|
||||||
|
|
||||||
unsigned int current = 0;
|
unsigned int current = 0;
|
||||||
while (current < total)
|
while (current < total)
|
||||||
{
|
{
|
||||||
auto uuid = uuids[current];
|
// Display banner for this task.
|
||||||
std::cout << "# [" << current << "] uuid '" << uuid << "'\n";
|
std::cout << banner (current + 1, total, width, "");
|
||||||
|
|
||||||
// TODO Run 'info' report for task
|
// Run 'info' report for task.
|
||||||
|
auto uuid = uuids[current];
|
||||||
std::string command = "task " + uuid + " information";
|
std::string command = "task " + uuid + " information";
|
||||||
std::cout << "# [" << current << "] command '" << command << "'\n";
|
|
||||||
system (command.c_str ());
|
system (command.c_str ());
|
||||||
|
|
||||||
// TODO Add prompt context '<ID> (<n> of <total>)'
|
|
||||||
std::string prompt = "(Enter) Skip, (e)dit, (c)ompleted, (d)eleted, Mark as (r)eviewed, (q)uit ";
|
|
||||||
|
|
||||||
// Display prompt, get input.
|
// Display prompt, get input.
|
||||||
command = getResponse (prompt);
|
auto response = getResponse (menu ());
|
||||||
|
|
||||||
if (command == "e") { editTask (uuid); ++current; }
|
if (response == "e") { editTask (uuid); ++current; }
|
||||||
else if (command == "r") { reviewTask (uuid); ++current; }
|
else if (response == "r") { reviewTask (uuid); ++current; }
|
||||||
else if (command == "c") { completeTask (uuid); ++current; }
|
else if (response == "c") { completeTask (uuid); ++current; }
|
||||||
else if (command == "d") { deleteTask (uuid); ++current; }
|
else if (response == "d") { deleteTask (uuid); ++current; }
|
||||||
else if (command == "q") { break; }
|
else if (response == "q") { break; }
|
||||||
else if (command == "") { std::cout << "Skipped\n"; ++current; }
|
else if (response == "") { std::cout << "Skipped\n"; ++current; }
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cout << format (STRING_REVIEW_UNRECOGNIZED, command) << "\n";
|
std::cout << format (STRING_REVIEW_UNRECOGNIZED, response) << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note that just hitting <Enter> yields an empty command, which does
|
// Note that just hitting <Enter> yields an empty command, which does
|
||||||
// nothing but advance to the next task.
|
// nothing but advance to the next task.
|
||||||
|
|
||||||
// TODO Remove prompt context.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << format (STRING_REVIEW_END, tasks, total) << "\n";
|
std::cout << format (STRING_REVIEW_END, tasks, total) << "\n";
|
||||||
|
@ -161,9 +187,9 @@ int cmdReview (const std::vector <std::string>& args)
|
||||||
output);
|
output);
|
||||||
if (status || output != "date\n")
|
if (status || output != "date\n")
|
||||||
{
|
{
|
||||||
execute ("task", {"rc.confirmation:no", "rc.verbose:nothing", "config", "uda.reviewed.type", "date"}, input, output);
|
execute ("task", {"rc.confirmation:no", "rc.verbose:nothing", "config", "uda.reviewed.type", "date"}, input, output);
|
||||||
execute ("task", {"rc.confirmation:no", "rc.verbose:nothing", "config", "uda.reviewed.label", "Reviewed"}, input, output);
|
execute ("task", {"rc.confirmation:no", "rc.verbose:nothing", "config", "uda.reviewed.label", "Reviewed"}, input, output);
|
||||||
execute ("task", {"rc.confirmation:no", "rc.verbose:nothing", "config", "review.period", "1week"}, input, output);
|
execute ("task", {"rc.confirmation:no", "rc.verbose:nothing", "config", "review.period", "1week"}, input, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obtain a list of UUIDs to review.
|
// Obtain a list of UUIDs to review.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue