- 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 () CmdAdd::CmdAdd ()
{ {
_keyword = "add"; _keyword = "add";
_usage = "task add [tags] [attrs] desc..."; _usage = "task add <modifications>";
_description = STRING_CMD_ADD_USAGE; _description = STRING_CMD_ADD_USAGE;
_read_only = false; _read_only = false;
_displays_id = false; _displays_id = false;

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -258,6 +258,22 @@
#define STRING_CMD_SUMMARY_AVG_AGE "Avg age" #define STRING_CMD_SUMMARY_AVG_AGE "Avg age"
#define STRING_CMD_SUMMARY_COMPLETE "Complete" #define STRING_CMD_SUMMARY_COMPLETE "Complete"
#define STRING_CMD_COUNT_USAGE "Shows only the number of matching tasks." #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 // Config
#define STRING_CONFIG_OVERNEST "Configuration file nested to more than 10 levels deep - this has to be a mistake." #define STRING_CONFIG_OVERNEST "Configuration file nested to more than 10 levels deep - this has to be a mistake."