mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Confirmation
- Implemented consistent confirmation.
This commit is contained in:
parent
a5961f6847
commit
1b54516b45
4 changed files with 19 additions and 50 deletions
|
@ -65,7 +65,7 @@ int CmdAnnotate::execute (std::string& output)
|
||||||
// Apply the command line modifications to the new task.
|
// Apply the command line modifications to the new task.
|
||||||
A3 modifications = context.a3.extract_modifications ();
|
A3 modifications = context.a3.extract_modifications ();
|
||||||
if (!modifications.size ())
|
if (!modifications.size ())
|
||||||
throw std::string (STRING_CMD_XPEND_NEED_TEXT);
|
throw std::string (STRING_CMD_MODIFY_NEED_TEXT);
|
||||||
|
|
||||||
std::vector <Task>::iterator task;
|
std::vector <Task>::iterator task;
|
||||||
for (task = filtered.begin (); task != filtered.end (); ++task)
|
for (task = filtered.begin (); task != filtered.end (); ++task)
|
||||||
|
|
|
@ -65,7 +65,7 @@ int CmdAppend::execute (std::string& output)
|
||||||
// Apply the command line modifications to the new task.
|
// Apply the command line modifications to the new task.
|
||||||
A3 modifications = context.a3.extract_modifications ();
|
A3 modifications = context.a3.extract_modifications ();
|
||||||
if (!modifications.size ())
|
if (!modifications.size ())
|
||||||
throw std::string (STRING_CMD_XPEND_NEED_TEXT);
|
throw std::string (STRING_CMD_MODIFY_NEED_TEXT);
|
||||||
|
|
||||||
std::vector <Task>::iterator task;
|
std::vector <Task>::iterator task;
|
||||||
for (task = filtered.begin (); task != filtered.end (); ++task)
|
for (task = filtered.begin (); task != filtered.end (); ++task)
|
||||||
|
|
|
@ -25,12 +25,10 @@
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
#define L10N // Localization complete.
|
#define L10N // Localization complete.
|
||||||
|
|
||||||
#include <sstream>
|
#include <iostream>
|
||||||
#include <Context.h>
|
#include <Context.h>
|
||||||
#include <Permission.h>
|
|
||||||
#include <util.h>
|
#include <util.h>
|
||||||
#include <text.h>
|
#include <text.h>
|
||||||
#include <i18n.h>
|
#include <i18n.h>
|
||||||
|
@ -54,7 +52,6 @@ int CmdPrepend::execute (std::string& output)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
std::stringstream out;
|
|
||||||
|
|
||||||
// Apply filter.
|
// Apply filter.
|
||||||
std::vector <Task> filtered;
|
std::vector <Task> filtered;
|
||||||
|
@ -68,11 +65,7 @@ int CmdPrepend::execute (std::string& output)
|
||||||
// Apply the command line modifications to the new task.
|
// Apply the command line modifications to the new task.
|
||||||
A3 modifications = context.a3.extract_modifications ();
|
A3 modifications = context.a3.extract_modifications ();
|
||||||
if (!modifications.size ())
|
if (!modifications.size ())
|
||||||
throw std::string (STRING_CMD_XPEND_NEED_TEXT);
|
throw std::string (STRING_CMD_MODIFY_NEED_TEXT);
|
||||||
|
|
||||||
Permission permission;
|
|
||||||
if (filtered.size () > (size_t) context.config.getInteger ("bulk"))
|
|
||||||
permission.bigSequence ();
|
|
||||||
|
|
||||||
std::vector <Task>::iterator task;
|
std::vector <Task>::iterator task;
|
||||||
for (task = filtered.begin (); task != filtered.end (); ++task)
|
for (task = filtered.begin (); task != filtered.end (); ++task)
|
||||||
|
@ -80,26 +73,17 @@ int CmdPrepend::execute (std::string& output)
|
||||||
Task before (*task);
|
Task before (*task);
|
||||||
|
|
||||||
// Prepend to the specified task.
|
// Prepend to the specified task.
|
||||||
std::string question = format (STRING_CMD_PREPEND_QUESTION,
|
std::string question = format (STRING_CMD_PREPEND_CONFIRM,
|
||||||
task->id,
|
task->id,
|
||||||
task->get ("description"));
|
task->get ("description"));
|
||||||
|
|
||||||
modify_task_description_prepend (*task, modifications);
|
modify_task_description_prepend (*task, modifications);
|
||||||
|
|
||||||
if (permission.confirmed (*task, taskDifferences (before, *task) + question))
|
if (permission (*task, taskDifferences (before, *task) + question, filtered.size ()))
|
||||||
{
|
{
|
||||||
context.tdb2.modify (*task);
|
context.tdb2.modify (*task);
|
||||||
++count;
|
++count;
|
||||||
|
feedback_affected (STRING_CMD_PREPEND_TASK, *task);
|
||||||
if (context.verbose ("affected") ||
|
|
||||||
context.config.getBoolean ("echo.command")) // Deprecated 2.0
|
|
||||||
out << format (task->has ("parent")
|
|
||||||
? STRING_CMD_PREPEND_RECURRING
|
|
||||||
: STRING_CMD_PREPEND_DELETING,
|
|
||||||
task->id,
|
|
||||||
task->get ("description"))
|
|
||||||
<< "\n";
|
|
||||||
|
|
||||||
context.footnote (onProjectChange (*task, true));
|
context.footnote (onProjectChange (*task, true));
|
||||||
|
|
||||||
// Prepend to siblings.
|
// Prepend to siblings.
|
||||||
|
@ -107,7 +91,7 @@ int CmdPrepend::execute (std::string& output)
|
||||||
{
|
{
|
||||||
std::vector <Task> siblings = context.tdb2.siblings (*task);
|
std::vector <Task> siblings = context.tdb2.siblings (*task);
|
||||||
if (siblings.size () &&
|
if (siblings.size () &&
|
||||||
confirm (STRING_CMD_PREPEND_CONF_REC))
|
confirm (STRING_CMD_PREPEND_CONFIRM_R))
|
||||||
{
|
{
|
||||||
std::vector <Task>::iterator sibling;
|
std::vector <Task>::iterator sibling;
|
||||||
for (sibling = siblings.begin (); sibling != siblings.end (); ++sibling)
|
for (sibling = siblings.begin (); sibling != siblings.end (); ++sibling)
|
||||||
|
@ -115,13 +99,7 @@ int CmdPrepend::execute (std::string& output)
|
||||||
modify_task_description_prepend (*sibling, modifications);
|
modify_task_description_prepend (*sibling, modifications);
|
||||||
context.tdb2.modify (*sibling);
|
context.tdb2.modify (*sibling);
|
||||||
++count;
|
++count;
|
||||||
|
feedback_affected (STRING_CMD_PREPEND_TASK_R, *sibling);
|
||||||
if (context.verbose ("affected") ||
|
|
||||||
context.config.getBoolean ("echo.command")) // Deprecated 2.0
|
|
||||||
out << format (STRING_CMD_PREPEND_RECURRING,
|
|
||||||
sibling->id,
|
|
||||||
sibling->get ("description"))
|
|
||||||
<< "\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prepend to the parent
|
// Prepend to the parent
|
||||||
|
@ -134,22 +112,13 @@ int CmdPrepend::execute (std::string& output)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
out << STRING_CMD_DELETE_NOT << "\n";
|
std::cout << STRING_CMD_PREPEND_NO << "\n";
|
||||||
rc = 1;
|
rc = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
context.tdb2.commit ();
|
context.tdb2.commit ();
|
||||||
|
feedback_affected (count == 1 ? STRING_CMD_PREPEND_1 : STRING_CMD_PREPEND_N, count);
|
||||||
if (context.verbose ("affected") ||
|
|
||||||
context.config.getBoolean ("echo.command")) // Deprecated 2.0
|
|
||||||
out << format ((count == 1
|
|
||||||
? STRING_CMD_PREPEND_SUMMARY
|
|
||||||
: STRING_CMD_PREPEND_SUMMARY_N),
|
|
||||||
count)
|
|
||||||
<< "\n";
|
|
||||||
|
|
||||||
output = out.str ();
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
16
src/en-US.h
16
src/en-US.h
|
@ -320,8 +320,6 @@
|
||||||
#define STRING_CMD_STOP_STOPPED "Stopped {1} task."
|
#define STRING_CMD_STOP_STOPPED "Stopped {1} task."
|
||||||
#define STRING_CMD_STOP_STOPPED_N "Stopped {1} tasks."
|
#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_USAGE "Appends text to an existing task description"
|
||||||
#define STRING_CMD_APPEND_1 "Appended {1} task."
|
#define STRING_CMD_APPEND_1 "Appended {1} task."
|
||||||
#define STRING_CMD_APPEND_N "Appended {1} tasks."
|
#define STRING_CMD_APPEND_N "Appended {1} tasks."
|
||||||
|
@ -333,13 +331,14 @@
|
||||||
#define STRING_CMD_APPEND_NO "Task not appended."
|
#define STRING_CMD_APPEND_NO "Task not appended."
|
||||||
|
|
||||||
#define STRING_CMD_PREPEND_USAGE "Prepends text to an existing task description"
|
#define STRING_CMD_PREPEND_USAGE "Prepends text to an existing task description"
|
||||||
#define STRING_CMD_PREPEND_SUMMARY "Prepended {1} task."
|
#define STRING_CMD_PREPEND_1 "Prepended {1} task."
|
||||||
#define STRING_CMD_PREPEND_SUMMARY_N "Prepended {1} tasks."
|
#define STRING_CMD_PREPEND_N "Prepended {1} tasks."
|
||||||
#define STRING_CMD_PREPEND_QUESTION "Prepend to task {1} '{2}'?"
|
#define STRING_CMD_PREPEND_TASK "Prepending to task {1} '{2}'."
|
||||||
#define STRING_CMD_PREPEND_RECURRING "Prepending to recurring task {1} '{2}'."
|
#define STRING_CMD_PREPEND_TASK_R "Prepending to recurring task {1} '{2}'."
|
||||||
#define STRING_CMD_PREPEND_DELETING "Prepending to task {1} '{2}'."
|
#define STRING_CMD_PREPEND_DELETING "Prepending to task {1} '{2}'."
|
||||||
#define STRING_CMD_PREPEND_CONF_REC "This is a recurring task. Do you want to prepend to all pending recurrences of this same task?"
|
#define STRING_CMD_PREPEND_CONFIRM_R "This is a recurring task. Do you want to prepend to all pending recurrences of this same task?"
|
||||||
#define STRING_CMD_XPEND_NEED_TEXT "Additional text must be provided."
|
#define STRING_CMD_PREPEND_CONFIRM "Prepend to task {1} '{2}'?"
|
||||||
|
#define STRING_CMD_PREPEND_NO "Task not prepended."
|
||||||
|
|
||||||
#define STRING_CMD_ANNO_USAGE "Adds an annotation to an existing task"
|
#define STRING_CMD_ANNO_USAGE "Adds an annotation to an existing task"
|
||||||
#define STRING_CMD_ANNO_CONFIRM "Annotate task {1} '{2}'?"
|
#define STRING_CMD_ANNO_CONFIRM "Annotate task {1} '{2}'?"
|
||||||
|
@ -419,6 +418,7 @@
|
||||||
#define STRING_CMD_MODIFY_SIMPLE "Modiying task {1} '{2}'."
|
#define STRING_CMD_MODIFY_SIMPLE "Modiying task {1} '{2}'."
|
||||||
#define STRING_CMD_MODIFY_NOT "Task not modified."
|
#define STRING_CMD_MODIFY_NOT "Task not modified."
|
||||||
#define STRING_CMD_MODIFY_RECUR "This is a recurring task. Do you want to modify all pending recurrences of this same task?"
|
#define STRING_CMD_MODIFY_RECUR "This is a recurring task. Do you want to modify all pending recurrences of this same task?"
|
||||||
|
#define STRING_CMD_MODIFY_NEED_TEXT "Additional text must be provided."
|
||||||
#define STRING_CMD_COLOR_USAGE "Displays all possible colors, a named sample, or a legend containing all currently defined colors"
|
#define STRING_CMD_COLOR_USAGE "Displays all possible colors, a named sample, or a legend containing all currently defined colors"
|
||||||
#define STRING_CMD_COLOR_HERE "Here are the colors currently in use:"
|
#define STRING_CMD_COLOR_HERE "Here are the colors currently in use:"
|
||||||
#define STRING_CMD_COLOR_COLOR "Color"
|
#define STRING_CMD_COLOR_COLOR "Color"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue