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
e73c255612
commit
af3bbc21d2
2 changed files with 38 additions and 45 deletions
|
@ -25,15 +25,14 @@
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
#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 <main.h>
|
|
||||||
#include <text.h>
|
#include <text.h>
|
||||||
#include <i18n.h>
|
#include <i18n.h>
|
||||||
|
#include <main.h>
|
||||||
#include <CmdDone.h>
|
#include <CmdDone.h>
|
||||||
|
|
||||||
extern Context context;
|
extern Context context;
|
||||||
|
@ -53,7 +52,6 @@ int CmdDone::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;
|
||||||
|
@ -64,70 +62,62 @@ int CmdDone::execute (std::string& output)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply the command line modifications to the completed 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 ();
|
|
||||||
|
|
||||||
bool nagged = false;
|
bool nagged = false;
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
Task before (*task);
|
||||||
|
|
||||||
if (task->getStatus () == Task::pending ||
|
if (task->getStatus () == Task::pending ||
|
||||||
task->getStatus () == Task::waiting)
|
task->getStatus () == Task::waiting)
|
||||||
{
|
{
|
||||||
Task before (*task);
|
// Complete the specified task.
|
||||||
|
std::string question = format (STRING_CMD_DONE_CONFIRM,
|
||||||
|
task->id,
|
||||||
|
task->get ("description"));
|
||||||
|
|
||||||
modify_task_annotate (*task, modifications);
|
modify_task_annotate (*task, modifications);
|
||||||
task->setStatus (Task::completed);
|
task->setStatus (Task::completed);
|
||||||
|
if (! task->has ("end"))
|
||||||
|
task->setEnd ();
|
||||||
|
|
||||||
// Stop the task, if started.
|
// Stop the task, if started.
|
||||||
if (task->has ("start") &&
|
if (task->has ("start") &&
|
||||||
context.config.getBoolean ("journal.time"))
|
context.config.getBoolean ("journal.time"))
|
||||||
task->addAnnotation (context.config.get ("journal.time.stop.annotation"));
|
task->addAnnotation (context.config.get ("journal.time.stop.annotation"));
|
||||||
|
|
||||||
if (taskDiff (before, *task))
|
if (permission (*task, taskDifferences (before, *task) + question, filtered.size ()))
|
||||||
{
|
{
|
||||||
if (permission.confirmed (before, taskDifferences (before, *task) + STRING_CMD_DONE_PROCEED))
|
updateRecurrenceMask (*task);
|
||||||
{
|
context.tdb2.modify (*task);
|
||||||
context.tdb2.modify (*task);
|
++count;
|
||||||
++count;
|
feedback_affected (STRING_CMD_DONE_TASK, *task);
|
||||||
|
if (!nagged)
|
||||||
if (context.verbose ("affected") ||
|
nagged = nag (*task);
|
||||||
context.config.getBoolean ("echo.command")) // Deprecated 2.0
|
dependencyChainOnComplete (*task);
|
||||||
out << format (STRING_CMD_DONE_COMPLETED, task->id, task->get ("description"))
|
context.footnote (onProjectChange (*task, false));
|
||||||
<< "\n";
|
}
|
||||||
|
else
|
||||||
dependencyChainOnComplete (*task);
|
{
|
||||||
context.footnote (onProjectChange (*task, false));
|
std::cout << STRING_CMD_DONE_NO << "\n";
|
||||||
|
rc = 1;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
updateRecurrenceMask (*task);
|
|
||||||
if (!nagged)
|
|
||||||
nagged = nag (*task);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
out << format (STRING_CMD_DONE_NOT_PENDING, task->id, task->get ("description"))
|
std::cout << format (STRING_CMD_DONE_NOTPEND,
|
||||||
<< "\n";
|
task->id,
|
||||||
|
task->get ("description"))
|
||||||
|
<< "\n";
|
||||||
rc = 1;
|
rc = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
context.tdb2.commit ();
|
context.tdb2.commit ();
|
||||||
|
feedback_affected (count == 1 ? STRING_CMD_DONE_1 : STRING_CMD_DONE_N, count);
|
||||||
if (context.verbose ("affected") ||
|
|
||||||
context.config.getBoolean ("echo.command")) // Deprecated 2.0
|
|
||||||
out << format ((count == 1
|
|
||||||
? STRING_CMD_DONE_MARKED
|
|
||||||
: STRING_CMD_DONE_MARKED_N),
|
|
||||||
count)
|
|
||||||
<< "\n";
|
|
||||||
|
|
||||||
output = out.str ();
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -262,12 +262,15 @@
|
||||||
#define STRING_CMD_GHISTORY_YEAR "Year"
|
#define STRING_CMD_GHISTORY_YEAR "Year"
|
||||||
#define STRING_CMD_GHISTORY_MONTH "Month"
|
#define STRING_CMD_GHISTORY_MONTH "Month"
|
||||||
#define STRING_CMD_GHISTORY_NUMBER "Number Added/Completed/Deleted"
|
#define STRING_CMD_GHISTORY_NUMBER "Number Added/Completed/Deleted"
|
||||||
|
|
||||||
#define STRING_CMD_DONE_USAGE "Marks the specified task as completed"
|
#define STRING_CMD_DONE_USAGE "Marks the specified task as completed"
|
||||||
#define STRING_CMD_DONE_QUESTION "Complete task {1} '{2}'?"
|
#define STRING_CMD_DONE_CONFIRM "Complete task {1} '{2}'?"
|
||||||
#define STRING_CMD_DONE_NOT "Task not completed."
|
#define STRING_CMD_DONE_TASK "Completed task {1} '{2}'."
|
||||||
#define STRING_CMD_DONE_NOT_PENDING "Task {1} '{2}' is neither pending nor waiting."
|
#define STRING_CMD_DONE_NO "Task not completed."
|
||||||
|
#define STRING_CMD_DONE_NOTPEND "Task {1} '{2}' is neither pending nor waiting."
|
||||||
#define STRING_CMD_DONE_1 "Completed {1} task."
|
#define STRING_CMD_DONE_1 "Completed {1} task."
|
||||||
#define STRING_CMD_DONE_N "Completed {1} tasks."
|
#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 "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_USAGE_2 "Shows only a list of all project names used"
|
||||||
#define STRING_CMD_PROJECTS_NO "No projects."
|
#define STRING_CMD_PROJECTS_NO "No projects."
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue