- Localized more commands.
This commit is contained in:
Paul Beckingham 2011-07-10 11:08:40 -04:00
parent ba723db9d7
commit e5139780ea
8 changed files with 85 additions and 80 deletions

View file

@ -40,7 +40,7 @@ extern Context context;
CmdAdd::CmdAdd ()
{
_keyword = "add";
_usage = "task add [tags] [attrs] desc...";
_usage = "task add <modifications>";
_description = STRING_CMD_ADD_USAGE;
_read_only = false;
_displays_id = false;

View file

@ -25,6 +25,8 @@
//
////////////////////////////////////////////////////////////////////////////////
#define L10N // Localization complete.
#include <sstream>
#include <Context.h>
#include <Permission.h>
@ -40,8 +42,8 @@ extern Context context;
CmdDelete::CmdDelete ()
{
_keyword = "delete";
_usage = "task delete ID";
_description = "Deletes the specified task.";
_usage = "task <filter> delete [<modifications>]";
_description = STRING_CMD_DELETE_USAGE;
_read_only = false;
_displays_id = false;
}
@ -83,21 +85,18 @@ int CmdDelete::execute (std::string& output)
modify_task_annotate (*task, modifications);
apply_defaults (*task);
std::stringstream question;
question << "Permanently delete task "
<< task->id
<< " '"
<< task->get ("description")
<< "'?";
std::string question = format (STRING_CMD_DELETE_QUESTION,
task->id,
task->get ("description"));
if (!context.config.getBoolean ("confirmation") || confirm (question.str ()))
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 != "")
{
if (confirm ("This is a recurring task. Do you want to delete all pending recurrences of this same task?"))
if (confirm (STRING_CMD_DELETE_CONF_RECUR))
{
// Scan all pending tasks for siblings of this task, and the parent
// itself, and delete them.
@ -112,7 +111,7 @@ int CmdDelete::execute (std::string& output)
// Don't want a 'delete' to clobber the end date that may have
// been written by a 'done' command.
if (! sibling->has ("end"))
sibling->set ("end", endTime);
sibling->setEnd ();
// Apply the command line modifications to the sibling.
modify_task_annotate (*sibling, modifications);
@ -122,12 +121,12 @@ int CmdDelete::execute (std::string& output)
context.tdb.update (*sibling);
++count;
// TODO Feedback.
if (context.config.getBoolean ("echo.command"))
out << "Deleting recurring task "
<< sibling->id
<< " '"
<< sibling->get ("description")
<< "'.\n";
out << format (STRING_CMD_DELETE_RECURRING,
sibling->id,
sibling->get ("description"))
<< "\n";
}
}
}
@ -140,17 +139,16 @@ int CmdDelete::execute (std::string& output)
// Don't want a 'delete' to clobber the end date that may have
// been written by a 'done' command.
if (! task->has ("end"))
task->set ("end", endTime);
task->setEnd ();
task->validate ();
context.tdb.update (*task);
++count;
out << "Deleting recurring task "
<< task->id
<< " '"
<< task->get ("description")
<< "'.\n";
out << format (STRING_CMD_DELETE_RECURRING,
task->id,
task->get ("description"))
<< "\n";
dependencyChainOnComplete (*task);
context.footnote (onProjectChange (*task));
@ -163,18 +161,17 @@ int CmdDelete::execute (std::string& output)
// Don't want a 'delete' to clobber the end date that may have
// been written by a 'done' command.
if (! task->has ("end"))
task->set ("end", endTime);
task->setEnd ();
task->validate ();
context.tdb.update (*task);
++count;
if (context.config.getBoolean ("echo.command"))
out << "Deleting task "
<< task->id
<< " '"
<< task->get ("description")
<< "'.\n";
out << format (STRING_CMD_DELETE_DELETING,
task->id,
task->get ("description"))
<< "\n";
dependencyChainOnComplete (*task);
context.footnote (onProjectChange (*task));
@ -182,17 +179,16 @@ int CmdDelete::execute (std::string& output)
}
else
{
out << "Task not deleted.\n";
out << STRING_CMD_DELETE_NOT << "\n";
rc = 1;
}
}
else
{
out << "Task "
<< task->id
<< " '"
<< task->get ("description")
<< "' is neither pending nor waiting.\n";
out << format (STRING_CMD_DELETE_NOTPEND,
task->id,
task->get ("description"))
<< "\n";
rc = 1;
}
}

View file

@ -41,7 +41,7 @@ extern Context context;
CmdDone::CmdDone ()
{
_keyword = "done";
_usage = "task done ID [tags] [attrs] [desc...]";
_usage = "task <filter> done [<modifications>]";
_description = STRING_CMD_DONE_USAGE;
_read_only = false;
_displays_id = false;
@ -87,12 +87,7 @@ int CmdDone::execute (std::string& output)
modify_task_annotate (*task, modifications);
apply_defaults (*task);
// Add an end date.
char entryTime[16];
sprintf (entryTime, "%u", (unsigned int) time (NULL));
task->set ("end", entryTime);
// Change status.
task->setEnd ();
task->setStatus (Task::completed);
// Stop the task, if started.

View file

@ -25,6 +25,8 @@
//
////////////////////////////////////////////////////////////////////////////////
#define L10N // Localization complete.
#include <sstream>
#include <Context.h>
#include <text.h>
@ -40,7 +42,7 @@ CmdDuplicate::CmdDuplicate ()
{
_keyword = "duplicate";
_usage = "task <filter> duplicate [<modifications>]";
_description = "Duplicates the specified tasks, and allows modifications.";
_description = STRING_CMD_DUPLICATE_USAGE;
_read_only = false;
_displays_id = false;
}
@ -88,9 +90,8 @@ int CmdDuplicate::execute (std::string& output)
dup.remove ("imak");
dup.remove ("imask");
out << "Note: task "
<< task->id
<< " was a recurring task. The duplicate task is not.\n";
out << format (STRING_CMD_DUPLICATE_NON_REC, task->id)
<< "\n";
}
modify_task_annotate (dup, modifications);
@ -103,11 +104,10 @@ int CmdDuplicate::execute (std::string& output)
++count;
if (context.config.getBoolean ("echo.command"))
out << "Duplicated "
<< task->id
<< " '"
<< task->get ("description")
<< "'.\n";
out << format (STRING_CMD_DUPLICATE_DONE,
task->id,
task->get ("description"))
<< "\n";
// TODO This should be a call in to feedback.cpp.
if (context.verbose ("new-id"))

View file

@ -173,11 +173,7 @@ CmdImport::fileType CmdImport::determineFileType (const std::vector <std::string
void CmdImport::decorateTask (Task& task)
{
if (!task.has ("entry"))
{
char entryTime[16];
sprintf (entryTime, "%u", (unsigned int) time (NULL));
task.set ("entry", entryTime);
}
task.setEntry ();
task.setStatus (Task::pending);

View file

@ -25,10 +25,13 @@
//
////////////////////////////////////////////////////////////////////////////////
#define L10N // Localization complete.
#include <sstream>
#include <Context.h>
#include <Permission.h>
#include <main.h>
#include <text.h>
#include <i18n.h>
#include <CmdStart.h>
@ -38,8 +41,8 @@ extern Context context;
CmdStart::CmdStart ()
{
_keyword = "start";
_usage = "task start ID";
_description = "Marks specified task as started.";
_usage = "task <filter> start [<modifications>]";
_description = STRING_CMD_START_USAGE;
_read_only = false;
_displays_id = false;
}
@ -102,11 +105,10 @@ int CmdStart::execute (std::string& output)
++count;
if (context.config.getBoolean ("echo.command"))
out << "Started "
<< task->id
<< " '"
<< task->get ("description")
<< "'.\n";
out << format (STRING_CMD_START_DONE,
task->id,
task->get ("description"))
<< "\n";
dependencyChainOnStart (*task);
}
@ -117,11 +119,10 @@ int CmdStart::execute (std::string& output)
}
else
{
out << "Task "
<< task->id
<< " '"
<< task->get ("description")
<< "' already started.\n";
out << format (STRING_CMD_START_ALREADY,
task->id,
task->get ("description"))
<< "\n";
rc = 1;
}
}

View file

@ -25,10 +25,13 @@
//
////////////////////////////////////////////////////////////////////////////////
#define L10N // Localization complete.
#include <sstream>
#include <Context.h>
#include <Permission.h>
#include <main.h>
#include <text.h>
#include <i18n.h>
#include <CmdStop.h>
@ -38,8 +41,8 @@ extern Context context;
CmdStop::CmdStop ()
{
_keyword = "stop";
_usage = "task stop ID";
_description = "Removes the 'start' time from a task.";
_usage = "task <filter> stop [<modifications>]";
_description = STRING_CMD_STOP_USAGE;
_read_only = false;
_displays_id = false;
}
@ -99,21 +102,19 @@ int CmdStop::execute (std::string& output)
++count;
if (context.config.getBoolean ("echo.command"))
out << "Stopped "
<< task->id
<< " '"
<< task->get ("description")
<< "'.\n";
out << format (STRING_CMD_STOP_DONE,
task->id,
task->get ("description"))
<< "\n";
}
}
}
else
{
out << "Task "
<< task->id
<< " '"
<< task->get ("description")
<< "' not started.\n";
out << format (STRING_CMD_STOP_NOT,
task->id,
task->get ("description"))
<< "\n";
rc = 1;
}
}

View file

@ -258,6 +258,22 @@
#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_NOTPEND "Task {1} '{2}' is neither pending nor waiting."
#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_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_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}'."
// Config
#define STRING_CONFIG_OVERNEST "Configuration file nested to more than 10 levels deep - this has to be a mistake."