mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Commands - done
- The 'done' command now functional. - Localized CmdDone.cpp.
This commit is contained in:
parent
1b90adc1aa
commit
877ecbc864
6 changed files with 54 additions and 48 deletions
12
src/Task.cpp
12
src/Task.cpp
|
@ -881,10 +881,14 @@ void Task::substitute (
|
|||
void Task::validate () const
|
||||
{
|
||||
// Every task needs an ID, entry and description attribute.
|
||||
if (!has ("uuid") ||
|
||||
!has ("entry") ||
|
||||
!has ("description"))
|
||||
throw std::string ("A task must have a description in order to be valid.");
|
||||
if (!has ("uuid"))
|
||||
throw std::string ("A task must have a UUID.");
|
||||
|
||||
if (!has ("entry"))
|
||||
throw std::string ("A task must have an entry timestamp.");
|
||||
|
||||
if (!has ("description"))
|
||||
throw std::string ("A task must have a description.");
|
||||
|
||||
if (get ("description") == "") // No i18n
|
||||
throw std::string ("Cannot add a task that is blank, or contains <CR> or <LF> characters.");
|
||||
|
|
|
@ -25,10 +25,14 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define L10N // Localization complete.
|
||||
|
||||
#include <sstream>
|
||||
#include <Context.h>
|
||||
#include <Permission.h>
|
||||
#include <main.h>
|
||||
#include <text.h>
|
||||
#include <i18n.h>
|
||||
#include <CmdDone.h>
|
||||
|
||||
extern Context context;
|
||||
|
@ -38,7 +42,7 @@ CmdDone::CmdDone ()
|
|||
{
|
||||
_keyword = "done";
|
||||
_usage = "task done ID [tags] [attrs] [desc...]";
|
||||
_description = "Marks the specified task as completed.";
|
||||
_description = STRING_CMD_DONE_USAGE;
|
||||
_read_only = false;
|
||||
_displays_id = false;
|
||||
}
|
||||
|
@ -47,44 +51,40 @@ CmdDone::CmdDone ()
|
|||
int CmdDone::execute (std::string& output)
|
||||
{
|
||||
int rc = 0;
|
||||
/*
|
||||
int count = 0;
|
||||
std::stringstream out;
|
||||
|
||||
std::vector <Task> tasks;
|
||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||
Filter filter;
|
||||
context.tdb.loadPending (tasks, filter);
|
||||
context.tdb.loadPending (tasks);
|
||||
|
||||
// Filter sequence.
|
||||
std::vector <Task> all = tasks;
|
||||
context.filter.applySequence (tasks, context.sequence);
|
||||
if (tasks.size () == 0)
|
||||
// Apply filter.
|
||||
std::vector <Task> filtered;
|
||||
filter (tasks, filtered);
|
||||
|
||||
if (filtered.size () == 0)
|
||||
{
|
||||
context.footnote ("No tasks specified.");
|
||||
context.footnote (STRING_FEEDBACK_NO_TASKS_SP);
|
||||
return 1;
|
||||
}
|
||||
|
||||
Permission permission;
|
||||
if (context.sequence.size () > (size_t) context.config.getInteger ("bulk"))
|
||||
if (filtered.size () > (size_t) context.config.getInteger ("bulk"))
|
||||
permission.bigSequence ();
|
||||
|
||||
bool nagged = false;
|
||||
std::vector <Task>::iterator task;
|
||||
for (task = tasks.begin (); task != tasks.end (); ++task)
|
||||
for (task = filtered.begin (); task != filtered.end (); ++task)
|
||||
{
|
||||
if (task->getStatus () == Task::pending ||
|
||||
task->getStatus () == Task::waiting)
|
||||
{
|
||||
Task before (*task);
|
||||
|
||||
// Apply other deltas.
|
||||
if (deltaDescription (*task))
|
||||
permission.bigChange ();
|
||||
|
||||
deltaTags (*task);
|
||||
deltaAttributes (*task);
|
||||
deltaSubstitutions (*task);
|
||||
// Apply the command line modifications to the new task.
|
||||
Arguments modifications = context.args.extract_modifications ();
|
||||
modify_task (*task, modifications);
|
||||
apply_defaults (*task);
|
||||
|
||||
// Add an end date.
|
||||
char entryTime[16];
|
||||
|
@ -104,16 +104,13 @@ int CmdDone::execute (std::string& output)
|
|||
|
||||
if (taskDiff (before, *task))
|
||||
{
|
||||
if (permission.confirmed (before, taskDifferences (before, *task) + "Proceed with change?"))
|
||||
if (permission.confirmed (before, taskDifferences (before, *task) + STRING_CMD_DONE_PROCEED))
|
||||
{
|
||||
context.tdb.update (*task);
|
||||
|
||||
if (context.config.getBoolean ("echo.command"))
|
||||
out << "Completed "
|
||||
<< task->id
|
||||
<< " '"
|
||||
<< task->get ("description")
|
||||
<< "'.\n";
|
||||
out << format (STRING_CMD_DONE_COMPLETED, task->id, task->get ("description"))
|
||||
<< "\n";
|
||||
|
||||
dependencyChainOnComplete (*task);
|
||||
context.footnote (onProjectChange (*task, false));
|
||||
|
@ -122,17 +119,14 @@ int CmdDone::execute (std::string& output)
|
|||
}
|
||||
}
|
||||
|
||||
updateRecurrenceMask (all, *task);
|
||||
updateRecurrenceMask (filtered, *task);
|
||||
if (!nagged)
|
||||
nagged = nag (*task);
|
||||
}
|
||||
else
|
||||
{
|
||||
out << "Task "
|
||||
<< task->id
|
||||
<< " '"
|
||||
<< task->get ("description")
|
||||
<< "' is neither pending nor waiting.\n";
|
||||
out << format (STRING_CMD_DONE_NOT_PENDING, task->id, task->get ("description"))
|
||||
<< "\n";
|
||||
rc = 1;
|
||||
}
|
||||
}
|
||||
|
@ -143,14 +137,14 @@ int CmdDone::execute (std::string& output)
|
|||
context.tdb.unlock ();
|
||||
|
||||
if (context.config.getBoolean ("echo.command"))
|
||||
out << "Marked "
|
||||
<< count
|
||||
<< " task"
|
||||
<< (count == 1 ? "" : "s")
|
||||
<< " as done.\n";
|
||||
if (count == 1)
|
||||
out << format (STRING_CMD_DONE_MARKED, count)
|
||||
<< "\n";
|
||||
else
|
||||
out << format (STRING_CMD_DONE_MARKED_N, count)
|
||||
<< "\n";
|
||||
|
||||
output = out.str ();
|
||||
*/
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
|
@ -190,7 +190,7 @@ int CmdHistoryMonthly::execute (std::string& output)
|
|||
<< "\n";
|
||||
else
|
||||
{
|
||||
out << STRING_CMD_HISTORY_NO_TASKS << "\n";
|
||||
out << STRING_FEEDBACK_NO_TASKS << "\n";
|
||||
rc = 1;
|
||||
}
|
||||
|
||||
|
@ -347,7 +347,7 @@ int CmdHistoryAnnual::execute (std::string& output)
|
|||
<< "\n";
|
||||
else
|
||||
{
|
||||
out << STRING_CMD_HISTORY_NO_TASKS << "\n";
|
||||
out << STRING_FEEDBACK_NO_TASKS << "\n";
|
||||
rc = 1;
|
||||
}
|
||||
|
||||
|
@ -546,7 +546,7 @@ int CmdGHistoryMonthly::execute (std::string& output)
|
|||
}
|
||||
else
|
||||
{
|
||||
out << STRING_CMD_HISTORY_NO_TASKS << "\n";
|
||||
out << STRING_FEEDBACK_NO_TASKS << "\n";
|
||||
rc = 1;
|
||||
}
|
||||
|
||||
|
@ -742,7 +742,7 @@ int CmdGHistoryAnnual::execute (std::string& output)
|
|||
}
|
||||
else
|
||||
{
|
||||
out << STRING_CMD_HISTORY_NO_TASKS << "\n";
|
||||
out << STRING_FEEDBACK_NO_TASKS << "\n";
|
||||
rc = 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ int CmdUrgency::execute (std::string& output)
|
|||
|
||||
if (filtered.size () == 0)
|
||||
{
|
||||
context.footnote (STRING_CMD_URGENCY_NO_TASKS);
|
||||
context.footnote (STRING_FEEDBACK_NO_TASKS_SP);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -360,7 +360,9 @@ void Command::modify_task (Task& task, Arguments& arguments)
|
|||
throw format (STRING_CMD_MOD_UNEXPECTED, arg->first);
|
||||
}
|
||||
|
||||
task.set ("description", description);
|
||||
// Only update description if one was specified.
|
||||
if (description.length ())
|
||||
task.set ("description", description);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
10
src/en-US.h
10
src/en-US.h
|
@ -169,7 +169,6 @@
|
|||
#define STRING_CMD_LOGO_COLOR_REQ "The logo command requires that color support is enabled."
|
||||
#define STRING_CMD_EXEC_USAGE "Executes external commands and scripts"
|
||||
#define STRING_CMD_URGENCY_USAGE "Displays the urgency measure of a task."
|
||||
#define STRING_CMD_URGENCY_NO_TASKS "No tasks specified."
|
||||
#define STRING_CMD_URGENCY_RESULT "task {1} urgency {2}"
|
||||
#define STRING_CMD_ADD_USAGE "Adds a new task."
|
||||
#define STRING_CMD_ADD_FEEDBACK "Created task {1}."
|
||||
|
@ -222,7 +221,6 @@
|
|||
#define STRING_CMD_HISTORY_DEL "Deleted"
|
||||
#define STRING_CMD_HISTORY_NET "Net"
|
||||
#define STRING_CMD_HISTORY_USAGE_A "Shows a report of task history, by year."
|
||||
#define STRING_CMD_HISTORY_NO_TASKS "No tasks."
|
||||
#define STRING_CMD_HISTORY_AVERAGE "Average"
|
||||
#define STRING_CMD_HISTORY_LEGEND "Legend: {1}, {2}, {3}"
|
||||
#define STRING_CMD_HISTORY_LEGEND_A "Legend: + added, X completed, - deleted"
|
||||
|
@ -231,6 +229,12 @@
|
|||
#define STRING_CMD_GHISTORY_YEAR "Year"
|
||||
#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_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"
|
||||
|
||||
// Config
|
||||
#define STRING_CONFIG_OVERNEST "Configuration file nested to more than 10 levels deep - this has to be a mistake."
|
||||
|
@ -272,6 +276,8 @@
|
|||
#define STRING_INFINITE_LOOP "Terminated substitution because more than {1} changes were made - infinite loop protection."
|
||||
|
||||
// Feedback
|
||||
#define STRING_FEEDBACK_NO_TASKS "No tasks."
|
||||
#define STRING_FEEDBACK_NO_TASKS_SP "No tasks specified."
|
||||
#define STRING_FEEDBACK_NO_MATCH "No matches."
|
||||
#define STRING_FEEDBACK_TASKS_SINGLE "(1 task)"
|
||||
#define STRING_FEEDBACK_TASKS_PLURAL "({1} tasks)"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue