mirror of
https://github.com/GothenburgBitFactory/taskshell.git
synced 2025-08-24 08:56:46 +02:00
Review: Snapshot
This commit is contained in:
parent
0517ae6e04
commit
9d0e051f51
1 changed files with 113 additions and 64 deletions
115
src/review.cpp
115
src/review.cpp
|
@ -34,14 +34,26 @@
|
||||||
#include <readline/history.h>
|
#include <readline/history.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <text.h>
|
||||||
|
#include <util.h>
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
static int reviewLoop (const std::string& uuid)
|
static int reviewLoop (const std::vector <std::string>& uuids)
|
||||||
{
|
{
|
||||||
// TODO Add prompt context '<ID> (<n> of <total>)'
|
int status = 0;
|
||||||
// TODO Present options '(Enter) Skip, (e)dit, (c)ompleted, (d)eleted, Mark as (r)eviewed, (q)uit'
|
|
||||||
std::string prompt = "(Enter) Skip, (e)dit, (c)ompleted, (d)eleted, Mark as (r)eviewed, (q)uit ";
|
for (unsigned int i = 0; i < uuids.size (); ++i)
|
||||||
|
{
|
||||||
|
auto uuid = uuids[i];
|
||||||
|
std::cout << "# [" << i << "] uuid '" << uuid << "'\n";
|
||||||
|
|
||||||
// TODO Run 'info' report for task
|
// TODO Run 'info' report for task
|
||||||
|
std::string command = "task " + uuid + " information";
|
||||||
|
std::cout << "# [" << i << "] command '" << command << "'\n";
|
||||||
|
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.
|
||||||
#ifdef HAVE_READLINE
|
#ifdef HAVE_READLINE
|
||||||
|
@ -56,11 +68,11 @@ static int reviewLoop (const std::string& uuid)
|
||||||
if (*line_read)
|
if (*line_read)
|
||||||
add_history (line_read);
|
add_history (line_read);
|
||||||
|
|
||||||
std::string command (line_read);
|
command = std::string (line_read);
|
||||||
|
std::cout << "# [" << i << "] command '" << command << "'\n";
|
||||||
free (line_read);
|
free (line_read);
|
||||||
#else
|
#else
|
||||||
std::cout << prompt;
|
std::cout << prompt;
|
||||||
std::string command;
|
|
||||||
std::getline (std::cin, command);
|
std::getline (std::cin, command);
|
||||||
if (std::cin.eof () == 1)
|
if (std::cin.eof () == 1)
|
||||||
{
|
{
|
||||||
|
@ -69,34 +81,40 @@ static int reviewLoop (const std::string& uuid)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int status = 0;
|
if (command == "e") // task <uuid> edit
|
||||||
if (command == "")
|
|
||||||
{
|
{
|
||||||
// TODO S --> nop
|
command = "task rc.confirmation:no rc.verbose:nothing " + uuid + " edit";
|
||||||
|
system (command.c_str ());
|
||||||
|
|
||||||
|
command = "task rc.confirmation:no rc.verbose:nothing " + uuid + " modify reviewed:now";
|
||||||
|
system (command.c_str ());
|
||||||
}
|
}
|
||||||
else if (command == "e")
|
else if (command == "r") // task <uuid> modify reviewed:now
|
||||||
{
|
{
|
||||||
// TODO E --> task edit <UUID>
|
command = "task rc.confirmation:no rc.verbose:nothing " + uuid + " modify reviewed:now";
|
||||||
|
system (command.c_str ());
|
||||||
}
|
}
|
||||||
else if (command == "r")
|
else if (command == "c") // task <uuid> done
|
||||||
{
|
{
|
||||||
// TODO R --> task <UUID> modify reviewed:now
|
command = "task rc.confirmation:no rc.verbose:nothing " + uuid + " done";
|
||||||
|
system (command.c_str ());
|
||||||
}
|
}
|
||||||
else if (command == "c")
|
else if (command == "d") // task rc.confirmation:no <uuid> delete
|
||||||
{
|
{
|
||||||
// TODO C --> task <UUID> done
|
command = "task rc.confirmation:no rc.verbose:nothing " + uuid + " delete";
|
||||||
|
system (command.c_str ());
|
||||||
}
|
}
|
||||||
else if (command == "d")
|
else if (command == "q") // end
|
||||||
{
|
{
|
||||||
// TODO D --> task rc.confirmation:no <UUID> delete
|
|
||||||
}
|
|
||||||
else if (command == "q")
|
|
||||||
{
|
|
||||||
// TODO Q --> end review
|
|
||||||
status = 1;
|
status = 1;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Note that just hitting <Enter> yields an empty command, which does
|
||||||
|
// nothing but advance to the next task.
|
||||||
|
|
||||||
// TODO Remove prompt context.
|
// TODO Remove prompt context.
|
||||||
|
}
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
@ -104,22 +122,53 @@ static int reviewLoop (const std::string& uuid)
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
int cmdReview (const std::vector <std::string>& args)
|
int cmdReview (const std::vector <std::string>& args)
|
||||||
{
|
{
|
||||||
// TODO Configure 'reviewed' UDA, if necessary.
|
// Configure 'reviewed' UDA, but only if necessary.
|
||||||
|
std::string input;
|
||||||
|
std::string output;
|
||||||
|
auto status = execute ("task",
|
||||||
|
{"_get", "rc.uda.reviewed.type"},
|
||||||
|
input,
|
||||||
|
output);
|
||||||
|
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.label", "Reviewed"},
|
||||||
|
input,
|
||||||
|
output);
|
||||||
|
execute ("task",
|
||||||
|
{"rc.confirmation:no",
|
||||||
|
"rc.verbose:nothing",
|
||||||
|
"config", "review.period", "1week"},
|
||||||
|
input,
|
||||||
|
output);
|
||||||
|
}
|
||||||
|
|
||||||
// TODO Generate list of tasks.
|
// TODO Generate list of tasks.
|
||||||
// - status 'Pending' or 'Waiting'
|
|
||||||
// - 'reviewed' attribute older than 'now - rc.review.period'
|
// - 'reviewed' attribute older than 'now - rc.review.period'
|
||||||
// - apply <filter>, if specified
|
// - apply <filter>, if specified
|
||||||
// - sort by ascending 'reviewed' date
|
status = execute ("task",
|
||||||
|
{"rc.report.review_temp.columns:uuid",
|
||||||
|
"rc.report.review_temp.sort:reviewed+",
|
||||||
|
// "rc.report.review_temp.filter:reviewed.before:now-1week",
|
||||||
|
"rc.verbose:nothing",
|
||||||
|
"(", "+PENDING", "or", "+WAITING", ")",
|
||||||
|
"review_temp"},
|
||||||
|
input,
|
||||||
|
output);
|
||||||
|
std::cout << "# output '" << output << "'\n";
|
||||||
|
|
||||||
|
// Iterate over each task in the list.
|
||||||
std::vector <std::string> uuids;
|
std::vector <std::string> uuids;
|
||||||
uuids.push_back ("one");
|
split (uuids, output, '\n');
|
||||||
uuids.push_back ("two");
|
reviewLoop (uuids);
|
||||||
|
|
||||||
// TODO Iterate over each task in the list.
|
|
||||||
|
|
||||||
for (auto& uuid : uuids)
|
|
||||||
while (reviewLoop (uuid) == 0)
|
|
||||||
;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue