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
02e7c4f3ce
commit
e73c255612
3 changed files with 33 additions and 79 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 <main.h>
|
#include <main.h>
|
||||||
#include <text.h>
|
#include <text.h>
|
||||||
#include <util.h>
|
#include <util.h>
|
||||||
|
@ -53,7 +52,6 @@ int CmdStart::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 CmdStart::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 ();
|
|
||||||
|
|
||||||
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)
|
||||||
|
@ -79,8 +73,8 @@ int CmdStart::execute (std::string& output)
|
||||||
{
|
{
|
||||||
Task before (*task);
|
Task before (*task);
|
||||||
|
|
||||||
// Complete the specified task.
|
// Start the specified task.
|
||||||
std::string question = format (STRING_CMD_START_QUESTION,
|
std::string question = format (STRING_CMD_START_CONFIRM,
|
||||||
task->id,
|
task->id,
|
||||||
task->get ("description"));
|
task->get ("description"));
|
||||||
|
|
||||||
|
@ -90,35 +84,26 @@ int CmdStart::execute (std::string& output)
|
||||||
if (context.config.getBoolean ("journal.time"))
|
if (context.config.getBoolean ("journal.time"))
|
||||||
task->addAnnotation (context.config.get ("journal.time.start.annotation"));
|
task->addAnnotation (context.config.get ("journal.time.start.annotation"));
|
||||||
|
|
||||||
if (permission.confirmed (*task, taskDifferences (before, *task) + question))
|
if (permission (*task, taskDifferences (before, *task) + question, filtered.size ()))
|
||||||
{
|
{
|
||||||
updateRecurrenceMask (*task);
|
updateRecurrenceMask (*task);
|
||||||
context.tdb2.modify (*task);
|
context.tdb2.modify (*task);
|
||||||
|
++count;
|
||||||
|
feedback_affected (STRING_CMD_START_TASK, *task);
|
||||||
if (!nagged)
|
if (!nagged)
|
||||||
nagged = nag (*task);
|
nagged = nag (*task);
|
||||||
++count;
|
|
||||||
|
|
||||||
if (context.verbose ("affected") ||
|
|
||||||
context.config.getBoolean ("echo.command")) // Deprecated 2.0
|
|
||||||
out << format (task->has ("parent")
|
|
||||||
? STRING_CMD_START_RECURRING
|
|
||||||
: STRING_CMD_START_TASK,
|
|
||||||
task->id,
|
|
||||||
task->get ("description"))
|
|
||||||
<< "\n";
|
|
||||||
|
|
||||||
dependencyChainOnStart (*task);
|
dependencyChainOnStart (*task);
|
||||||
context.footnote (onProjectChange (*task, false));
|
context.footnote (onProjectChange (*task, false));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
out << format (STRING_CMD_START_NOT, task->id) << "\n";
|
std::cout << STRING_CMD_START_NO << "\n";
|
||||||
rc = 1;
|
rc = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
out << format (STRING_CMD_START_ALREADY,
|
std::cout << format (STRING_CMD_START_ALREADY,
|
||||||
task->id,
|
task->id,
|
||||||
task->get ("description"))
|
task->get ("description"))
|
||||||
<< "\n";
|
<< "\n";
|
||||||
|
@ -127,16 +112,7 @@ int CmdStart::execute (std::string& output)
|
||||||
}
|
}
|
||||||
|
|
||||||
context.tdb2.commit ();
|
context.tdb2.commit ();
|
||||||
|
feedback_affected (count == 1 ? STRING_CMD_START_1 : STRING_CMD_START_N, count);
|
||||||
if (context.verbose ("affected") ||
|
|
||||||
context.config.getBoolean ("echo.command")) // Deprecated 2.0
|
|
||||||
out << format ((count == 1
|
|
||||||
? STRING_CMD_START_STARTED
|
|
||||||
: STRING_CMD_START_STARTED_N),
|
|
||||||
count)
|
|
||||||
<< "\n";
|
|
||||||
|
|
||||||
output = out.str ();
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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 <main.h>
|
#include <main.h>
|
||||||
#include <text.h>
|
#include <text.h>
|
||||||
#include <i18n.h>
|
#include <i18n.h>
|
||||||
|
@ -52,7 +51,6 @@ int CmdStop::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;
|
||||||
|
@ -66,10 +64,6 @@ int CmdStop::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)
|
||||||
{
|
{
|
||||||
|
@ -77,8 +71,8 @@ int CmdStop::execute (std::string& output)
|
||||||
{
|
{
|
||||||
Task before (*task);
|
Task before (*task);
|
||||||
|
|
||||||
// Complete the specified task.
|
// Stop the specified task.
|
||||||
std::string question = format (STRING_CMD_STOP_QUESTION,
|
std::string question = format (STRING_CMD_STOP_CONFIRM,
|
||||||
task->id,
|
task->id,
|
||||||
task->get ("description"));
|
task->get ("description"));
|
||||||
|
|
||||||
|
@ -88,33 +82,24 @@ int CmdStop::execute (std::string& output)
|
||||||
if (context.config.getBoolean ("journal.time"))
|
if (context.config.getBoolean ("journal.time"))
|
||||||
task->addAnnotation (context.config.get ("journal.time.stop.annotation"));
|
task->addAnnotation (context.config.get ("journal.time.stop.annotation"));
|
||||||
|
|
||||||
if (permission.confirmed (*task, taskDifferences (before, *task) + question))
|
if (permission (*task, taskDifferences (before, *task) + question, filtered.size ()))
|
||||||
{
|
{
|
||||||
updateRecurrenceMask (*task);
|
updateRecurrenceMask (*task);
|
||||||
context.tdb2.modify (*task);
|
context.tdb2.modify (*task);
|
||||||
++count;
|
++count;
|
||||||
|
feedback_affected (STRING_CMD_STOP_TASK, *task);
|
||||||
if (context.verbose ("affected") ||
|
|
||||||
context.config.getBoolean ("echo.command")) // Deprecated 2.0
|
|
||||||
out << format (task->has ("parent")
|
|
||||||
? STRING_CMD_STOP_RECURRING
|
|
||||||
: STRING_CMD_STOP_TASK,
|
|
||||||
task->id,
|
|
||||||
task->get ("description"))
|
|
||||||
<< "\n";
|
|
||||||
|
|
||||||
dependencyChainOnStart (*task);
|
dependencyChainOnStart (*task);
|
||||||
context.footnote (onProjectChange (*task, false));
|
context.footnote (onProjectChange (*task, false));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
out << format (STRING_CMD_STOP_NOT, task->id) << "\n";
|
std::cout << STRING_CMD_STOP_NO << "\n";
|
||||||
rc = 1;
|
rc = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
out << format (STRING_CMD_STOP_ALREADY,
|
std::cout << format (STRING_CMD_STOP_ALREADY,
|
||||||
task->id,
|
task->id,
|
||||||
task->get ("description"))
|
task->get ("description"))
|
||||||
<< "\n";
|
<< "\n";
|
||||||
|
@ -123,16 +108,7 @@ int CmdStop::execute (std::string& output)
|
||||||
}
|
}
|
||||||
|
|
||||||
context.tdb2.commit ();
|
context.tdb2.commit ();
|
||||||
|
feedback_affected (count == 1 ? STRING_CMD_STOP_1 : STRING_CMD_STOP_N, count);
|
||||||
if (context.verbose ("affected") ||
|
|
||||||
context.config.getBoolean ("echo.command")) // Deprecated 2.0
|
|
||||||
out << format ((count == 1
|
|
||||||
? STRING_CMD_STOP_STOPPED
|
|
||||||
: STRING_CMD_STOP_STOPPED_N),
|
|
||||||
count)
|
|
||||||
<< "\n";
|
|
||||||
|
|
||||||
output = out.str ();
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
18
src/en-US.h
18
src/en-US.h
|
@ -303,22 +303,24 @@
|
||||||
#define STRING_CMD_DUPLICATE_NOT "Task not duplicated."
|
#define STRING_CMD_DUPLICATE_NOT "Task not duplicated."
|
||||||
#define STRING_CMD_DUPLICATE_DUP_1 "Duplicated {1} task."
|
#define STRING_CMD_DUPLICATE_DUP_1 "Duplicated {1} task."
|
||||||
#define STRING_CMD_DUPLICATE_DUP_N "Duplicated {1} tasks."
|
#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_USAGE "Marks specified task as started"
|
||||||
|
#define STRING_CMD_START_NO "Task not started."
|
||||||
#define STRING_CMD_START_ALREADY "Task {1} '{2}' already started."
|
#define STRING_CMD_START_ALREADY "Task {1} '{2}' already started."
|
||||||
#define STRING_CMD_START_RECURRING "Starting recurring task {1} '{2}'."
|
#define STRING_CMD_START_RECURRING "Starting recurring task {1} '{2}'."
|
||||||
#define STRING_CMD_START_TASK "Starting 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_CONFIRM "Start task {1} '{2}'?"
|
||||||
#define STRING_CMD_START_STARTED "Started {1} task."
|
#define STRING_CMD_START_1 "Started {1} task."
|
||||||
#define STRING_CMD_START_STARTED_N "Started {1} tasks."
|
#define STRING_CMD_START_N "Started {1} tasks."
|
||||||
|
|
||||||
#define STRING_CMD_STOP_USAGE "Removes the 'start' time from a task"
|
#define STRING_CMD_STOP_USAGE "Removes the 'start' time from a task"
|
||||||
#define STRING_CMD_STOP_NOT "Task {1} not stopped."
|
#define STRING_CMD_STOP_NO "Task not stopped."
|
||||||
#define STRING_CMD_STOP_ALREADY "Task {1} '{2}' not started."
|
#define STRING_CMD_STOP_ALREADY "Task {1} '{2}' not started."
|
||||||
#define STRING_CMD_STOP_RECURRING "Stopping recurring task {1} '{2}'."
|
#define STRING_CMD_STOP_RECURRING "Stopping recurring task {1} '{2}'."
|
||||||
#define STRING_CMD_STOP_TASK "Stopping 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_CONFIRM "Stop task {1} '{2}'?"
|
||||||
#define STRING_CMD_STOP_STOPPED "Stopped {1} task."
|
#define STRING_CMD_STOP_1 "Stopped {1} task."
|
||||||
#define STRING_CMD_STOP_STOPPED_N "Stopped {1} tasks."
|
#define STRING_CMD_STOP_N "Stopped {1} tasks."
|
||||||
|
|
||||||
#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."
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue