mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-25 21:27:19 +02:00
Confirmation
- Implemented consistent confirmation.
This commit is contained in:
parent
6e1ad5207d
commit
821c554e41
2 changed files with 102 additions and 120 deletions
|
@ -25,12 +25,10 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#define L10N // Localization complete.
|
||||
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
#include <Context.h>
|
||||
#include <Permission.h>
|
||||
#include <util.h>
|
||||
#include <text.h>
|
||||
#include <i18n.h>
|
||||
|
@ -54,7 +52,7 @@ int CmdDelete::execute (std::string& output)
|
|||
{
|
||||
int rc = 0;
|
||||
int count = 0;
|
||||
std::stringstream out;
|
||||
//std::stringstream out;
|
||||
|
||||
// Apply filter.
|
||||
std::vector <Task> filtered;
|
||||
|
@ -71,121 +69,80 @@ int CmdDelete::execute (std::string& output)
|
|||
std::vector <Task>::iterator task;
|
||||
for (task = filtered.begin (); task != filtered.end (); ++task)
|
||||
{
|
||||
Task before (*task);
|
||||
|
||||
if (task->getStatus () == Task::pending ||
|
||||
task->getStatus () == Task::waiting)
|
||||
{
|
||||
modify_task_annotate (*task, modifications);
|
||||
|
||||
std::string question = format (STRING_CMD_DELETE_QUESTION,
|
||||
// Delete the specified task.
|
||||
std::string question = format (STRING_CMD_DELETE_CONFIRM,
|
||||
task->id,
|
||||
task->get ("description"));
|
||||
|
||||
if (!context.config.getBoolean ("confirmation") || confirm (question))
|
||||
{
|
||||
// Check for the more complex case of a recurring task. If this is a
|
||||
// recurring task, get confirmation to delete them all.
|
||||
std::string parent = task->get ("parent");
|
||||
if (parent != "")
|
||||
{
|
||||
std::vector <Task> siblings;
|
||||
modify_task_annotate (*task, modifications);
|
||||
task->setStatus (Task::deleted);
|
||||
if (! task->has ("end"))
|
||||
task->setEnd ();
|
||||
|
||||
if (context.config.getBoolean ("confirmation") &&
|
||||
confirm (STRING_CMD_DELETE_CONF_RECUR))
|
||||
if (permission (*task, question, filtered.size ()))
|
||||
{
|
||||
updateRecurrenceMask (*task);
|
||||
context.tdb2.modify (*task);
|
||||
++count;
|
||||
feedback_affected (STRING_CMD_DELETE_TASK *task);
|
||||
dependencyChainOnComplete (*task);
|
||||
context.footnote (onProjectChange (*task, true));
|
||||
|
||||
// Delete siblings.
|
||||
if (task->has ("parent"))
|
||||
{
|
||||
std::vector <Task> siblings = context.tdb2.siblings (*task);
|
||||
if (siblings.size () &&
|
||||
confirm (STRING_CMD_DELETE_CONFIRM_R))
|
||||
{
|
||||
// Scan all pending tasks for siblings of this task, and the parent
|
||||
// itself, and delete them.
|
||||
siblings = context.tdb2.siblings (*task);
|
||||
std::vector <Task>::iterator sibling;
|
||||
for (sibling = siblings.begin (); sibling != siblings.end (); ++sibling)
|
||||
{
|
||||
if (sibling->get ("parent") == parent ||
|
||||
sibling->get ("uuid") == parent)
|
||||
{
|
||||
sibling->setStatus (Task::deleted);
|
||||
modify_task_annotate (*sibling, modifications);
|
||||
sibling->setStatus (Task::deleted);
|
||||
if (! sibling->has ("end"))
|
||||
sibling->setEnd ();
|
||||
|
||||
// Don't want a 'delete' to clobber the end date that may have
|
||||
// been written by a 'done' command.
|
||||
if (! sibling->has ("end"))
|
||||
sibling->setEnd ();
|
||||
|
||||
// Apply the command line modifications to the sibling.
|
||||
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_DELETE_RECURRING,
|
||||
sibling->id,
|
||||
sibling->get ("description"))
|
||||
<< "\n";
|
||||
}
|
||||
updateRecurrenceMask (*sibling);
|
||||
context.tdb2.modify (*sibling);
|
||||
++count;
|
||||
feedback_affected (STRING_CMD_DELETE_TASK_R, *sibling);
|
||||
}
|
||||
|
||||
// Delete the parent
|
||||
Task parent;
|
||||
context.tdb2.get (task->get ("parent"), parent);
|
||||
parent.setStatus (Task::deleted);
|
||||
if (! parent.has ("end"))
|
||||
parent.setEnd ();
|
||||
|
||||
context.tdb2.modify (parent);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Update mask in parent.
|
||||
task->setStatus (Task::deleted);
|
||||
updateRecurrenceMask (*task);
|
||||
|
||||
// Don't want a 'delete' to clobber the end date that may have
|
||||
// been written by a 'done' command.
|
||||
if (! task->has ("end"))
|
||||
task->setEnd ();
|
||||
|
||||
context.tdb2.modify (*task);
|
||||
++count;
|
||||
|
||||
out << format (STRING_CMD_DELETE_RECURRING,
|
||||
task->id,
|
||||
task->get ("description"))
|
||||
<< "\n";
|
||||
|
||||
dependencyChainOnComplete (*task);
|
||||
context.footnote (onProjectChange (*task));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
task->setStatus (Task::deleted);
|
||||
|
||||
// Don't want a 'delete' to clobber the end date that may have
|
||||
// been written by a 'done' command.
|
||||
if (! task->has ("end"))
|
||||
task->setEnd ();
|
||||
|
||||
context.tdb2.modify (*task);
|
||||
++count;
|
||||
|
||||
if (context.verbose ("affected") ||
|
||||
context.config.getBoolean ("echo.command")) // Deprecated 2.0
|
||||
out << format (STRING_CMD_DELETE_DELETING,
|
||||
task->id,
|
||||
task->get ("description"))
|
||||
<< "\n";
|
||||
|
||||
dependencyChainOnComplete (*task);
|
||||
context.footnote (onProjectChange (*task));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
out << STRING_CMD_DELETE_NOT << "\n";
|
||||
std::cout << STRING_CMD_DELETE_NO << "\n";
|
||||
rc = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
out << format (STRING_CMD_DELETE_NOTPEND,
|
||||
task->id,
|
||||
task->get ("description"))
|
||||
std::cout << format (STRING_CMD_DELETE_NOTPEND,
|
||||
task->id,
|
||||
task->get ("description"))
|
||||
<< "\n";
|
||||
rc = 1;
|
||||
}
|
||||
}
|
||||
|
||||
context.tdb2.commit ();
|
||||
output = out.str ();
|
||||
feedback_affected (count == 1 ? STRING_CMD_DELETE_1 : STRING_CMD_DELETE_N, count);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
85
src/en-US.h
85
src/en-US.h
|
@ -25,7 +25,6 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// This file contains all the strings that should be localized. If a string is
|
||||
|
@ -203,7 +202,6 @@
|
|||
#define STRING_CMD_ADD_USAGE "Adds a new task"
|
||||
#define STRING_CMD_ADD_FEEDBACK "Created task {1}."
|
||||
#define STRING_CMD_ADD_BAD_ATTRIBUTE "Unrecognized attribute '{1}'."
|
||||
#define STRING_CMD_MOD_UNEXPECTED "Unexpected argument '{1}' found while modifying a task."
|
||||
#define STRING_CMD_LOG_USAGE "Adds a new task that is already completed"
|
||||
#define STRING_CMD_LOG_NO_RECUR "You cannot log recurring tasks."
|
||||
#define STRING_CMD_LOG_NO_WAITING "You cannot log waiting tasks."
|
||||
|
@ -265,11 +263,11 @@
|
|||
#define STRING_CMD_GHISTORY_MONTH "Month"
|
||||
#define STRING_CMD_GHISTORY_NUMBER "Number Added/Completed/Deleted"
|
||||
#define STRING_CMD_DONE_USAGE "Marks the specified task as completed"
|
||||
#define STRING_CMD_DONE_PROCEED "Proceed with change?"
|
||||
#define STRING_CMD_DONE_COMPLETED "Completed {1} '{2}'."
|
||||
#define STRING_CMD_DONE_QUESTION "Complete task {1} '{2}'?"
|
||||
#define STRING_CMD_DONE_NOT "Task not completed."
|
||||
#define STRING_CMD_DONE_NOT_PENDING "Task {1} '{2}' is neither pending nor waiting."
|
||||
#define STRING_CMD_DONE_MARKED "Marked {1} task as done."
|
||||
#define STRING_CMD_DONE_MARKED_N "Marked {1} tasks as done."
|
||||
#define STRING_CMD_DONE_1 "Completed {1} task."
|
||||
#define STRING_CMD_DONE_N "Completed {1} tasks."
|
||||
#define STRING_CMD_PROJECTS_USAGE "Shows a list of all project names used, and how many tasks are in each"
|
||||
#define STRING_CMD_PROJECTS_USAGE_2 "Shows only a list of all project names used"
|
||||
#define STRING_CMD_PROJECTS_NO "No projects."
|
||||
|
@ -288,35 +286,64 @@
|
|||
#define STRING_CMD_SUMMARY_AVG_AGE "Avg age"
|
||||
#define STRING_CMD_SUMMARY_COMPLETE "Complete"
|
||||
#define STRING_CMD_COUNT_USAGE "Shows only the number of matching tasks"
|
||||
|
||||
#define STRING_CMD_DELETE_USAGE "Deletes the specified task"
|
||||
#define STRING_CMD_DELETE_QUESTION "Permanently delete task {1} '{2}'?"
|
||||
#define STRING_CMD_DELETE_RECURRING "Deleting recurring task {1} '{2}'."
|
||||
#define STRING_CMD_DELETE_DELETING "Deleting task {1} '{2}'."
|
||||
#define STRING_CMD_DELETE_CONF_RECUR "This is a recurring task. Do you want to delete all pending recurrences of this same task?"
|
||||
#define STRING_CMD_DELETE_NOT "Task not deleted."
|
||||
#define STRING_CMD_DELETE_CONFIRM "Permanently delete task {1} '{2}'?"
|
||||
#define STRING_CMD_DELETE_TASK "Deleting task {1} '{2}'."
|
||||
#define STRING_CMD_DELETE_TASK_R "Deleting recurring task {1} '{2}'."
|
||||
#define STRING_CMD_DELETE_CONFIRM_R "This is a recurring task. Do you want to delete all pending recurrences of this same task?"
|
||||
#define STRING_CMD_DELETE_NO "Task not deleted."
|
||||
#define STRING_CMD_DELETE_NOTPEND "Task {1} '{2}' is neither pending nor waiting."
|
||||
#define STRING_CMD_DELETE_1 "Deleted {1} task."
|
||||
#define STRING_CMD_DELETE_N "Deleted {1} tasks."
|
||||
|
||||
#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_DONE "Duplicated {1} '{2}'."
|
||||
#define STRING_CMD_DUPLICATE_DUP "Duplicated task {1} '{2}'."
|
||||
#define STRING_CMD_DUPLICATE_NOT "Task not duplicated."
|
||||
#define STRING_CMD_DUPLICATE_DUP_1 "Duplicated {1} task."
|
||||
#define STRING_CMD_DUPLICATE_DUP_N "Duplicated {1} tasks."
|
||||
#define STRING_CMD_START_NOT "Task {1} not started."
|
||||
#define STRING_CMD_START_USAGE "Marks specified task as started"
|
||||
#define STRING_CMD_START_DONE "Started {1} '{2}'."
|
||||
#define STRING_CMD_START_ALREADY "Task {1} '{2}' already started."
|
||||
#define STRING_CMD_START_RECURRING "Starting recurring task {1} '{2}'."
|
||||
#define STRING_CMD_START_TASK "Starting task {1} '{2}'."
|
||||
#define STRING_CMD_START_QUESTION "Start task {1} '{2}'?"
|
||||
#define STRING_CMD_START_STARTED "Started {1} task."
|
||||
#define STRING_CMD_START_STARTED_N "Started {1} tasks."
|
||||
#define STRING_CMD_STOP_USAGE "Removes the 'start' time from a task"
|
||||
#define STRING_CMD_STOP_NOT "Task {1} '{2}' not started."
|
||||
#define STRING_CMD_STOP_DONE "Stopped {1} '{2}'."
|
||||
#define STRING_CMD_STOP_NOT "Task {1} not stopped."
|
||||
#define STRING_CMD_STOP_ALREADY "Task {1} '{2}' not started."
|
||||
#define STRING_CMD_STOP_RECURRING "Stopping recurring task {1} '{2}'."
|
||||
#define STRING_CMD_STOP_TASK "Stopping task {1} '{2}'."
|
||||
#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_APPEND_USAGE "Appends text to an existing task description"
|
||||
#define STRING_CMD_APPEND_DONE "Appended to task {1}."
|
||||
#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_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_PREPEND_USAGE "Prepends text to an existing task description"
|
||||
#define STRING_CMD_PREPEND_DONE "Prepended to task {1}."
|
||||
#define STRING_CMD_PREPEND_SUMMARY "Prepended {1} task."
|
||||
#define STRING_CMD_PREPEND_SUMMARY_N "Prepended {1} tasks."
|
||||
#define STRING_CMD_PREPEND_QUESTION "Prepend to task {1} '{2}'?"
|
||||
#define STRING_CMD_PREPEND_RECURRING "Prepending to recurring 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_XPEND_NEED_TEXT "Additional text must be provided."
|
||||
|
||||
#define STRING_CMD_ANNO_USAGE "Adds an annotation to an existing task"
|
||||
#define STRING_CMD_ANNO_DONE "Annotated {1} '{2}'"
|
||||
#define STRING_CMD_ANNO_SUMMARY "Annotated {1} task."
|
||||
#define STRING_CMD_ANNO_SUMMARY_N "Annotated {1} tasks."
|
||||
#define STRING_CMD_ANNO_CONFIRM "Annotate task {1} '{2}'?"
|
||||
#define STRING_CMD_ANNO_TASK "Annotating task {1} '{2}'."
|
||||
#define STRING_CMD_ANNO_TASK_R "Annotating recurring task {1} '{2}'."
|
||||
#define STRING_CMD_ANNO_CONFIRM_R "This is a recurring task. Do you want to annotate all pending recurrences of this same task?"
|
||||
#define STRING_CMD_ANNO_NO "Task not annotated."
|
||||
#define STRING_CMD_ANNO_1 "Annotated {1} task."
|
||||
#define STRING_CMD_ANNO_N "Annotated {1} tasks."
|
||||
|
||||
#define STRING_CMD_COLUMNS_USAGE "Displays all supported columns and formatting styles"
|
||||
#define STRING_CMD_COLUMNS_NOTE "* Means default format, and therefore optional. For example, 'due' and 'due.formatted' are equivalent."
|
||||
#define STRING_CMD_COLUMNS_USAGE2 "Displays only a list of supported columns"
|
||||
|
@ -325,6 +352,9 @@
|
|||
#define STRING_CMD_DENO_NONE "The specified task has no annotations that can be deleted."
|
||||
#define STRING_CMD_DENO_FOUND "Found annotation '{1}' and deleted it."
|
||||
#define STRING_CMD_DENO_NOMATCH "Did not find any matching annotation to be deleted for '{1}'."
|
||||
#define STRING_CMD_DENO_TASK "Denotated {1} task."
|
||||
#define STRING_CMD_DENO_TASKS "Denotated {1} tasks."
|
||||
#define STRING_CMD_DENO_QUESTION "Denotate task {1} '{2}'?"
|
||||
#define STRING_CMD_IMPORT_USAGE "Imports JSON files"
|
||||
#define STRING_CMD_IMPORT_SUMMARY "Imported {1} tasks."
|
||||
#define STRING_CMD_IMPORT_NOFILE "You must specify a file to import."
|
||||
|
@ -376,11 +406,13 @@
|
|||
#define STRING_CMD_MODIFY_UNTIL "You cannot specify an until date for a non-recurring task."
|
||||
#define STRING_CMD_MODIFY_REM_DUE "You cannot remove the due date from a recurring task."
|
||||
#define STRING_CMD_MODIFY_REC_ALWAYS "You cannot remove the recurrence from a recurring task."
|
||||
#define STRING_CMD_MODIFY_INSTANCES "Task {1} is a recurring task, and all other instances of this task will be modified."
|
||||
#define STRING_CMD_MODIFY_NOW_RECUR "Task {1} is now a recurring task."
|
||||
#define STRING_CMD_MODIFY_PROCEED "Proceed with change?"
|
||||
#define STRING_CMD_MODIFY_TASK "Modified {1} task."
|
||||
#define STRING_CMD_MODIFY_TASKS "Modified {1} tasks."
|
||||
#define STRING_CMD_MODIFY_QUESTION "Modify task {1} '{2}'?"
|
||||
#define STRING_CMD_MODIFY_RECURRING "Modiying recurring task {1} '{2}'."
|
||||
#define STRING_CMD_MODIFY_SIMPLE "Modiying task {1} '{2}'."
|
||||
#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_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_COLOR "Color"
|
||||
|
@ -530,7 +562,6 @@
|
|||
// TODO Move each of these to appropriate section.
|
||||
#define STRING_UNKNOWN_ERROR "Unknown error."
|
||||
#define STRING_NO_HOME "Could not read home directory from the passwd file."
|
||||
#define STRING_TAGS_NO_COMMAS "Tags are not permitted to contain commas."
|
||||
#define STRING_TRIVIAL_INPUT "You must specify a command or a task to modify."
|
||||
#define STRING_ASSUME_INFO "No command specified - assuming 'information'."
|
||||
#define STRING_INFINITE_LOOP "Terminated substitution because more than {1} changes were made - infinite loop protection."
|
||||
|
@ -565,10 +596,6 @@
|
|||
#define STRING_LUA_BAD_HOOK_DEF "Malformed hook definition '{1}'."
|
||||
#define STRING_LUA_BAD_EVENT "Unrecognized hook event '{1}'."
|
||||
|
||||
// Permission
|
||||
#define STRING_PERM_TASK_LINE "Task {1} \"{2}\""
|
||||
#define STRING_PERM_RECURRING "(Recurring)"
|
||||
|
||||
// Record
|
||||
#define STRING_RECORD_EMPTY "Empty record in input."
|
||||
#define STRING_RECORD_JUNK_AT_EOL "Unrecognized characters at end of line."
|
||||
|
@ -604,8 +631,6 @@
|
|||
#define STRING_TASK_DEPEND_DUP "Task {1} already depends on task {2}."
|
||||
#define STRING_TASK_DEPEND_CIRCULAR "Circular dependency detected and disallowed."
|
||||
#define STRING_TASK_DEPEND_NO_UUID "Could not find a UUID for id {1}."
|
||||
#define STRING_TASK_VALID_UUID "A task must have a UUID."
|
||||
#define STRING_TASK_VALID_ENTRY "A task must have an entry timestamp."
|
||||
#define STRING_TASK_VALID_DESC "A task must have a description."
|
||||
#define STRING_TASK_VALID_BLANK "Cannot add a task that is blank."
|
||||
#define STRING_TASK_VALID_WAIT "Warning: You have specified a 'wait' date that is after the 'due' date."
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue