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
6aee2fc7b9
commit
a5961f6847
3 changed files with 20 additions and 45 deletions
|
@ -27,9 +27,8 @@
|
|||
|
||||
#define L10N // Localization complete.
|
||||
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
#include <Context.h>
|
||||
#include <Permission.h>
|
||||
#include <util.h>
|
||||
#include <text.h>
|
||||
#include <i18n.h>
|
||||
|
@ -53,7 +52,6 @@ int CmdAppend::execute (std::string& output)
|
|||
{
|
||||
int rc = 0;
|
||||
int count = 0;
|
||||
std::stringstream out;
|
||||
|
||||
// Apply filter.
|
||||
std::vector <Task> filtered;
|
||||
|
@ -69,36 +67,23 @@ int CmdAppend::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);
|
||||
|
||||
// Append to the specified task.
|
||||
std::string question = format (STRING_CMD_APPEND_QUESTION,
|
||||
std::string question = format (STRING_CMD_APPEND_CONFIRM,
|
||||
task->id,
|
||||
task->get ("description"));
|
||||
|
||||
modify_task_description_append (*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_APPEND_RECURRING
|
||||
: STRING_CMD_APPEND_DELETING,
|
||||
task->id,
|
||||
task->get ("description"))
|
||||
<< "\n";
|
||||
|
||||
feedback_affected (STRING_CMD_APPEND_TASK, *task);
|
||||
context.footnote (onProjectChange (*task, true));
|
||||
|
||||
// Append to siblings.
|
||||
|
@ -106,7 +91,7 @@ int CmdAppend::execute (std::string& output)
|
|||
{
|
||||
std::vector <Task> siblings = context.tdb2.siblings (*task);
|
||||
if (siblings.size () &&
|
||||
confirm (STRING_CMD_APPEND_CONF_RECUR))
|
||||
confirm (STRING_CMD_APPEND_CONFIRM_R))
|
||||
{
|
||||
std::vector <Task>::iterator sibling;
|
||||
for (sibling = siblings.begin (); sibling != siblings.end (); ++sibling)
|
||||
|
@ -114,13 +99,7 @@ int CmdAppend::execute (std::string& output)
|
|||
modify_task_description_append (*sibling, modifications);
|
||||
context.tdb2.modify (*sibling);
|
||||
++count;
|
||||
|
||||
if (context.verbose ("affected") ||
|
||||
context.config.getBoolean ("echo.command")) // Deprecated 2.0
|
||||
out << format (STRING_CMD_APPEND_RECURRING,
|
||||
sibling->id,
|
||||
sibling->get ("description"))
|
||||
<< "\n";
|
||||
feedback_affected (STRING_CMD_APPEND_TASK_R, *sibling);
|
||||
}
|
||||
|
||||
// Append to the parent
|
||||
|
@ -133,22 +112,13 @@ int CmdAppend::execute (std::string& output)
|
|||
}
|
||||
else
|
||||
{
|
||||
out << STRING_CMD_DELETE_NOT << "\n";
|
||||
std::cout << STRING_CMD_APPEND_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_APPEND_SUMMARY
|
||||
: STRING_CMD_APPEND_SUMMARY_N),
|
||||
count)
|
||||
<< "\n";
|
||||
|
||||
output = out.str ();
|
||||
feedback_affected (count == 1 ? STRING_CMD_APPEND_1 : STRING_CMD_APPEND_N, count);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
|
@ -52,7 +52,6 @@ int CmdDelete::execute (std::string& output)
|
|||
{
|
||||
int rc = 0;
|
||||
int count = 0;
|
||||
//std::stringstream out;
|
||||
|
||||
// Apply filter.
|
||||
std::vector <Task> filtered;
|
||||
|
@ -89,7 +88,7 @@ int CmdDelete::execute (std::string& output)
|
|||
updateRecurrenceMask (*task);
|
||||
context.tdb2.modify (*task);
|
||||
++count;
|
||||
feedback_affected (STRING_CMD_DELETE_TASK *task);
|
||||
feedback_affected (STRING_CMD_DELETE_TASK, *task);
|
||||
dependencyChainOnComplete (*task);
|
||||
context.footnote (onProjectChange (*task, true));
|
||||
|
||||
|
|
16
src/en-US.h
16
src/en-US.h
|
@ -319,13 +319,19 @@
|
|||
#define STRING_CMD_STOP_QUESTION "Stop task {1} '{2}'?"
|
||||
#define STRING_CMD_STOP_STOPPED "Stopped {1} task."
|
||||
#define STRING_CMD_STOP_STOPPED_N "Stopped {1} tasks."
|
||||
|
||||
#define STRING_CMD_DELETE_NOTPEND "Task {1} '{2}' is neither pending nor waiting."
|
||||
|
||||
#define STRING_CMD_APPEND_USAGE "Appends text to an existing task description"
|
||||
#define STRING_CMD_APPEND_SUMMARY "Appended {1} task."
|
||||
#define STRING_CMD_APPEND_SUMMARY_N "Appended {1} tasks."
|
||||
#define STRING_CMD_APPEND_QUESTION "Append to task {1} '{2}'?"
|
||||
#define STRING_CMD_APPEND_RECURRING "Appending to recurring task {1} '{2}'."
|
||||
#define STRING_CMD_APPEND_1 "Appended {1} task."
|
||||
#define STRING_CMD_APPEND_N "Appended {1} tasks."
|
||||
#define STRING_CMD_APPEND_TASK "Appending to task {1} '{2}'."
|
||||
#define STRING_CMD_APPEND_TASK_R "Appending to recurring task {1} '{2}'."
|
||||
#define STRING_CMD_APPEND_DELETING "Appending to task {1} '{2}'."
|
||||
#define STRING_CMD_APPEND_CONF_RECUR "This is a recurring task. Do you want to append to all pending recurrences of this same task?"
|
||||
#define STRING_CMD_APPEND_CONFIRM_R "This is a recurring task. Do you want to append to all pending recurrences of this same task?"
|
||||
#define STRING_CMD_APPEND_CONFIRM "Append to task {1} '{2}'?"
|
||||
#define STRING_CMD_APPEND_NO "Task not appended."
|
||||
|
||||
#define STRING_CMD_PREPEND_USAGE "Prepends text to an existing task description"
|
||||
#define STRING_CMD_PREPEND_SUMMARY "Prepended {1} task."
|
||||
#define STRING_CMD_PREPEND_SUMMARY_N "Prepended {1} tasks."
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue