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
1b54516b45
commit
02e7c4f3ce
4 changed files with 25 additions and 31 deletions
|
@ -27,9 +27,8 @@
|
|||
|
||||
#define L10N // Localization complete.
|
||||
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
#include <Context.h>
|
||||
#include <Permission.h>
|
||||
#include <text.h>
|
||||
#include <util.h>
|
||||
#include <i18n.h>
|
||||
|
@ -53,7 +52,6 @@ int CmdDenotate::execute (std::string& output)
|
|||
{
|
||||
int rc = 0;
|
||||
int count = 0;
|
||||
std::stringstream out;
|
||||
bool sensitive = context.config.getBoolean ("search.case.sensitive");
|
||||
|
||||
// Apply filter.
|
||||
|
@ -72,10 +70,6 @@ int CmdDenotate::execute (std::string& output)
|
|||
|
||||
std::string pattern = words.combine ();
|
||||
|
||||
Permission permission;
|
||||
if (filtered.size () > (size_t) context.config.getInteger ("bulk"))
|
||||
permission.bigSequence ();
|
||||
|
||||
std::vector <Task>::iterator task;
|
||||
for (task = filtered.begin (); task != filtered.end (); ++task)
|
||||
{
|
||||
|
@ -118,39 +112,26 @@ int CmdDenotate::execute (std::string& output)
|
|||
|
||||
if (taskDiff (before, *task))
|
||||
{
|
||||
std::string question = format (STRING_CMD_DENO_QUESTION,
|
||||
std::string question = format (STRING_CMD_DENO_CONFIRM,
|
||||
task->id,
|
||||
task->get ("description"));
|
||||
|
||||
if (permission.confirmed (*task, taskDifferences (before, *task) + question))
|
||||
if (permission (*task, taskDifferences (before, *task) + question, filtered.size ()))
|
||||
{
|
||||
++count;
|
||||
context.tdb2.modify (*task);
|
||||
if (context.verbose ("affected") ||
|
||||
context.config.getBoolean ("echo.command")) // Deprecated 2.0
|
||||
out << format (STRING_CMD_DENO_FOUND, anno)
|
||||
<< "\n";
|
||||
feedback_affected (format (STRING_CMD_DENO_FOUND, anno));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
out << format (STRING_CMD_DENO_NOMATCH, pattern)
|
||||
<< "\n";
|
||||
std::cout << format (STRING_CMD_DENO_NOMATCH, pattern) << "\n";
|
||||
rc = 1;
|
||||
}
|
||||
}
|
||||
|
||||
context.tdb2.commit ();
|
||||
|
||||
if (context.verbose ("affected") ||
|
||||
context.config.getBoolean ("echo.command")) // Deprecated 2.0
|
||||
out << format ((count == 1
|
||||
? STRING_CMD_DENO_TASK
|
||||
: STRING_CMD_DENO_TASKS),
|
||||
count)
|
||||
<< "\n";
|
||||
|
||||
output = out.str ();
|
||||
feedback_affected (count == 1 ? STRING_CMD_DENO_1 : STRING_CMD_DENO_N, count);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
10
src/en-US.h
10
src/en-US.h
|
@ -325,7 +325,6 @@
|
|||
#define STRING_CMD_APPEND_N "Appended {1} tasks."
|
||||
#define STRING_CMD_APPEND_TASK "Appending to task {1} '{2}'."
|
||||
#define STRING_CMD_APPEND_TASK_R "Appending to recurring task {1} '{2}'."
|
||||
#define STRING_CMD_APPEND_DELETING "Appending to task {1} '{2}'."
|
||||
#define STRING_CMD_APPEND_CONFIRM_R "This is a recurring task. Do you want to append to all pending recurrences of this same task?"
|
||||
#define STRING_CMD_APPEND_CONFIRM "Append to task {1} '{2}'?"
|
||||
#define STRING_CMD_APPEND_NO "Task not appended."
|
||||
|
@ -335,7 +334,6 @@
|
|||
#define STRING_CMD_PREPEND_N "Prepended {1} tasks."
|
||||
#define STRING_CMD_PREPEND_TASK "Prepending to 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_CONFIRM_R "This is a recurring task. Do you want to prepend to all pending recurrences of this same task?"
|
||||
#define STRING_CMD_PREPEND_CONFIRM "Prepend to task {1} '{2}'?"
|
||||
#define STRING_CMD_PREPEND_NO "Task not prepended."
|
||||
|
@ -352,14 +350,16 @@
|
|||
#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"
|
||||
|
||||
#define STRING_CMD_DENO_USAGE "Deletes an annotation"
|
||||
#define STRING_CMD_DENO_WORDS "An annotation pattern must be provided."
|
||||
#define STRING_CMD_DENO_NONE "The specified task has no annotations that can be deleted."
|
||||
#define STRING_CMD_DENO_CONFIRM "Denotate task {1} '{2}'?"
|
||||
#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_DENO_1 "Denotated {1} task."
|
||||
#define STRING_CMD_DENO_N "Denotated {1} tasks."
|
||||
|
||||
#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."
|
||||
|
|
|
@ -295,6 +295,18 @@ std::string renderAttribute (const std::string& name, const std::string& value)
|
|||
return value;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Implements:
|
||||
// <string>
|
||||
void feedback_affected (const std::string& effect)
|
||||
{
|
||||
if (context.verbose ("affected") ||
|
||||
context.config.getBoolean ("echo.command")) // Deprecated 2.0
|
||||
{
|
||||
std::cout << effect << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Implements:
|
||||
// Deleted 3 tasks
|
||||
|
|
|
@ -74,8 +74,9 @@ bool taskDiff (const Task&, const Task&);
|
|||
std::string taskDifferences (const Task&, const Task&);
|
||||
std::string taskInfoDifferences (const Task&, const Task&);
|
||||
std::string renderAttribute (const std::string&, const std::string&);
|
||||
void feedback_affected (const std::string&, const Task&);
|
||||
void feedback_affected (const std::string&);
|
||||
void feedback_affected (const std::string&, int);
|
||||
void feedback_affected (const std::string&, const Task&);
|
||||
|
||||
// sort.cpp
|
||||
void sort_tasks (std::vector <Task>&, std::vector <int>&, const std::string&);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue