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
af3bbc21d2
commit
a36cd3cbd1
2 changed files with 16 additions and 35 deletions
|
@ -27,9 +27,8 @@
|
||||||
|
|
||||||
#define L10N // Localization complete.
|
#define L10N // Localization complete.
|
||||||
|
|
||||||
#include <sstream>
|
#include <iostream>
|
||||||
#include <Context.h>
|
#include <Context.h>
|
||||||
#include <Permission.h>
|
|
||||||
#include <text.h>
|
#include <text.h>
|
||||||
#include <util.h>
|
#include <util.h>
|
||||||
#include <i18n.h>
|
#include <i18n.h>
|
||||||
|
@ -53,7 +52,6 @@ int CmdDuplicate::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;
|
||||||
|
@ -67,10 +65,6 @@ int CmdDuplicate::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 ();
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
@ -91,50 +85,36 @@ int CmdDuplicate::execute (std::string& output)
|
||||||
dup.remove ("imak");
|
dup.remove ("imak");
|
||||||
dup.remove ("imask");
|
dup.remove ("imask");
|
||||||
|
|
||||||
out << format (STRING_CMD_DUPLICATE_NON_REC, task->id)
|
std::cout << format (STRING_CMD_DUPLICATE_NON_REC, task->id)
|
||||||
<< "\n";
|
<< "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
modify_task_annotate (dup, modifications);
|
modify_task_annotate (dup, modifications);
|
||||||
|
|
||||||
if (permission.confirmed (dup,
|
if (permission (dup,
|
||||||
format (STRING_CMD_DONE_QUESTION,
|
format (STRING_CMD_DUPLICATE_CONFIRM,
|
||||||
task->id,
|
task->id,
|
||||||
task->get ("description"))))
|
task->get ("description")),
|
||||||
|
filtered.size ()))
|
||||||
{
|
{
|
||||||
context.tdb2.add (dup);
|
context.tdb2.add (dup);
|
||||||
++count;
|
++count;
|
||||||
|
feedback_affected (STRING_CMD_DUPLICATE_TASK, *task);
|
||||||
if (context.verbose ("affected") ||
|
|
||||||
context.config.getBoolean ("echo.command")) // Deprecated 2.0
|
|
||||||
out << format (STRING_CMD_DUPLICATE_DUP,
|
|
||||||
task->id,
|
|
||||||
task->get ("description"))
|
|
||||||
<< "\n";
|
|
||||||
|
|
||||||
if (context.verbose ("new-id"))
|
if (context.verbose ("new-id"))
|
||||||
out << format (STRING_CMD_ADD_FEEDBACK, context.tdb2.next_id ()) + "\n";
|
std::cout << format (STRING_CMD_ADD_FEEDBACK, context.tdb2.next_id ()) + "\n";
|
||||||
|
|
||||||
context.footnote (onProjectChange (*task, false));
|
context.footnote (onProjectChange (*task, false));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
out << STRING_CMD_DUPLICATE_NOT << "\n";
|
std::cout << STRING_CMD_DUPLICATE_NO << "\n";
|
||||||
rc = 1;
|
rc = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
context.tdb2.commit ();
|
context.tdb2.commit ();
|
||||||
|
feedback_affected (count == 1 ? STRING_CMD_DUPLICATE_1 : STRING_CMD_DUPLICATE_N, count);
|
||||||
if (context.verbose ("affected") ||
|
|
||||||
context.config.getBoolean ("echo.command")) // Deprecated 2.0
|
|
||||||
out << format ((count == 1
|
|
||||||
? STRING_CMD_DUPLICATE_DUP_1
|
|
||||||
: STRING_CMD_DUPLICATE_DUP_N),
|
|
||||||
count)
|
|
||||||
<< "\n";
|
|
||||||
|
|
||||||
output = out.str ();
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -302,10 +302,11 @@
|
||||||
|
|
||||||
#define STRING_CMD_DUPLICATE_USAGE "Duplicates the specified tasks, and allows modifications"
|
#define STRING_CMD_DUPLICATE_USAGE "Duplicates the specified tasks, and allows modifications"
|
||||||
#define STRING_CMD_DUPLICATE_NON_REC "Note: task {1} was a recurring task. The duplicate task is not."
|
#define STRING_CMD_DUPLICATE_NON_REC "Note: task {1} was a recurring task. The duplicate task is not."
|
||||||
#define STRING_CMD_DUPLICATE_DUP "Duplicated task {1} '{2}'."
|
#define STRING_CMD_DUPLICATE_CONFIRM "Duplicate task {1} '{2}'?"
|
||||||
#define STRING_CMD_DUPLICATE_NOT "Task not duplicated."
|
#define STRING_CMD_DUPLICATE_TASK "Duplicated task {1} '{2}'."
|
||||||
#define STRING_CMD_DUPLICATE_DUP_1 "Duplicated {1} task."
|
#define STRING_CMD_DUPLICATE_NO "Task not duplicated."
|
||||||
#define STRING_CMD_DUPLICATE_DUP_N "Duplicated {1} tasks."
|
#define STRING_CMD_DUPLICATE_1 "Duplicated {1} task."
|
||||||
|
#define STRING_CMD_DUPLICATE_N "Duplicated {1} tasks."
|
||||||
|
|
||||||
#define STRING_CMD_START_USAGE "Marks specified task as started"
|
#define STRING_CMD_START_USAGE "Marks specified task as started"
|
||||||
#define STRING_CMD_START_NO "Task not started."
|
#define STRING_CMD_START_NO "Task not started."
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue