mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Confirmation
- Implemented consistent confirmation.
This commit is contained in:
parent
821c554e41
commit
6b40b0fb4a
1 changed files with 8 additions and 38 deletions
|
@ -27,9 +27,8 @@
|
|||
|
||||
#define L10N // Localization complete.
|
||||
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
#include <Context.h>
|
||||
#include <Permission.h>
|
||||
#include <main.h>
|
||||
#include <text.h>
|
||||
#include <util.h>
|
||||
|
@ -53,7 +52,6 @@ int CmdAnnotate::execute (std::string& output)
|
|||
{
|
||||
int rc = 0;
|
||||
int count = 0;
|
||||
std::stringstream out;
|
||||
|
||||
// Apply filter.
|
||||
std::vector <Task> filtered;
|
||||
|
@ -69,36 +67,23 @@ int CmdAnnotate::execute (std::string& output)
|
|||
if (!modifications.size ())
|
||||
throw std::string (STRING_CMD_XPEND_NEED_TEXT);
|
||||
|
||||
Permission permission;
|
||||
if (filtered.size () > (size_t) context.config.getInteger ("bulk"))
|
||||
permission.bigSequence ();
|
||||
|
||||
std::vector <Task>::iterator task;
|
||||
for (task = filtered.begin (); task != filtered.end (); ++task)
|
||||
{
|
||||
Task before (*task);
|
||||
|
||||
// Annotate the specified task.
|
||||
std::string question = format (STRING_CMD_ANNO_QUESTION,
|
||||
std::string question = format (STRING_CMD_ANNO_CONFIRM,
|
||||
task->id,
|
||||
task->get ("description"));
|
||||
|
||||
modify_task_annotate (*task, modifications);
|
||||
|
||||
if (permission.confirmed (*task, taskDifferences (before, *task) + question))
|
||||
if (permission (*task, taskDifferences (before, *task) + question, filtered.size ()))
|
||||
{
|
||||
context.tdb2.modify (*task);
|
||||
++count;
|
||||
|
||||
if (context.verbose ("affected") ||
|
||||
context.config.getBoolean ("echo.command")) // Deprecated 2.0
|
||||
out << format (task->has ("parent")
|
||||
? STRING_CMD_ANNO_RECURRING
|
||||
: STRING_CMD_ANNO_DELETING,
|
||||
task->id,
|
||||
task->get ("description"))
|
||||
<< "\n";
|
||||
|
||||
feedback_affected (STRING_CMD_ANNO_TASK, *task);
|
||||
dependencyChainOnComplete (*task);
|
||||
context.footnote (onProjectChange (*task, true));
|
||||
|
||||
|
@ -107,7 +92,7 @@ int CmdAnnotate::execute (std::string& output)
|
|||
{
|
||||
std::vector <Task> siblings = context.tdb2.siblings (*task);
|
||||
if (siblings.size () &&
|
||||
confirm (STRING_CMD_ANNO_CONF_RECUR))
|
||||
confirm (STRING_CMD_ANNO_CONFIRM_R))
|
||||
{
|
||||
std::vector <Task>::iterator sibling;
|
||||
for (sibling = siblings.begin (); sibling != siblings.end (); ++sibling)
|
||||
|
@ -115,13 +100,7 @@ int CmdAnnotate::execute (std::string& output)
|
|||
modify_task_annotate (*sibling, modifications);
|
||||
context.tdb2.modify (*sibling);
|
||||
++count;
|
||||
|
||||
if (context.verbose ("affected") ||
|
||||
context.config.getBoolean ("echo.command")) // Deprecated 2.0
|
||||
out << format (STRING_CMD_ANNO_RECURRING,
|
||||
sibling->id,
|
||||
sibling->get ("description"))
|
||||
<< "\n";
|
||||
feedback_affected (STRING_CMD_ANNO_TASK_R, *sibling);
|
||||
}
|
||||
|
||||
// Annotate the parent
|
||||
|
@ -134,22 +113,13 @@ int CmdAnnotate::execute (std::string& output)
|
|||
}
|
||||
else
|
||||
{
|
||||
out << STRING_CMD_DELETE_NOT << "\n";
|
||||
std::cout << STRING_CMD_ANNO_NO << "\n";
|
||||
rc = 1;
|
||||
}
|
||||
}
|
||||
|
||||
context.tdb2.commit ();
|
||||
|
||||
if (context.verbose ("affected") ||
|
||||
context.config.getBoolean ("echo.command")) // Deprecated 2.0
|
||||
out << format ((count == 1
|
||||
? STRING_CMD_ANNO_SUMMARY
|
||||
: STRING_CMD_ANNO_SUMMARY_N),
|
||||
count)
|
||||
<< "\n";
|
||||
|
||||
output = out.str ();
|
||||
feedback_affected (count == 1 ? STRING_CMD_ANNO_1 : STRING_CMD_ANNO_N, count);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue