- Localized more commands.
This commit is contained in:
Paul Beckingham 2011-09-24 10:56:14 -04:00
parent 63203cd91a
commit 31aa0de426
5 changed files with 62 additions and 29 deletions

View file

@ -31,6 +31,8 @@
#include <stdlib.h> #include <stdlib.h>
#include <RX.h> #include <RX.h>
#include <Context.h> #include <Context.h>
#include <i18n.h>
#include <text.h>
#include <util.h> #include <util.h>
#include <cmake.h> #include <cmake.h>
#include <commit.h> #include <commit.h>
@ -51,7 +53,7 @@ CmdDiagnostics::CmdDiagnostics ()
{ {
_keyword = "diagnostics"; _keyword = "diagnostics";
_usage = "task diagnostics"; _usage = "task diagnostics";
_description = "Shows information needed when reporting a problem."; _description = STRING_CMD_DIAG_USAGE;
_read_only = true; _read_only = true;
_displays_id = false; _displays_id = false;
} }
@ -70,7 +72,7 @@ int CmdDiagnostics::execute (std::string& output)
<< bold.colorize (PACKAGE_STRING) << bold.colorize (PACKAGE_STRING)
<< "\n"; << "\n";
out << " Platform: " out << " " << STRING_CMD_DIAG_PLATFORM << ": "
<< <<
#if defined (DARWIN) #if defined (DARWIN)
"Darwin" "Darwin"
@ -87,17 +89,18 @@ int CmdDiagnostics::execute (std::string& output)
#elif defined (LINUX) #elif defined (LINUX)
"Linux" "Linux"
#else #else
"<unknown>" STRING_CMD_DIAG_UNKNOWN
#endif #endif
<< "\n\n"; << "\n\n";
// Compiler. // Compiler.
out << bold.colorize ("Compiler") out << bold.colorize (STRING_CMD_DIAG_COMPILER)
<< "\n" << "\n"
#ifdef __VERSION__ #ifdef __VERSION__
<< " Version: " << __VERSION__ << "\n" << " " << STRING_CMD_DIAG_VERSION << ": "
<< __VERSION__ << "\n"
#endif #endif
<< " Caps:" << " " << STRING_CMD_DIAG_CAPS << ":"
#ifdef __STDC__ #ifdef __STDC__
<< " +stdc" << " +stdc"
#endif #endif
@ -125,7 +128,7 @@ int CmdDiagnostics::execute (std::string& output)
<< " +vp" << sizeof (void*) << " +vp" << sizeof (void*)
<< "\n\n"; << "\n\n";
out << bold.colorize ("Libraries") out << bold.colorize (STRING_CMD_DIAG_LIBRARIES)
<< "\n"; << "\n";
out << " Lua: " out << " Lua: "
@ -136,14 +139,14 @@ int CmdDiagnostics::execute (std::string& output)
#endif #endif
<< "\n\n"; << "\n\n";
out << bold.colorize ("Build Features") out << bold.colorize (STRING_CMD_DIAG_FEATURES)
<< "\n" << "\n"
// Build date. // Build date.
<< " Built: " << __DATE__ << " " << __TIME__ << "\n" << " " << STRING_CMD_DIAG_BUILT << ": " << __DATE__ << " " << __TIME__ << "\n"
<< " Commit: " << COMMIT << "\n" << " " << STRING_CMD_DIAG_COMMIT << ": " << COMMIT << "\n"
<< " CMake: " << CMAKE_VERSION << "\n" << " CMake: " << CMAKE_VERSION << "\n"
<< " Caps:" << " " << STRING_CMD_DIAG_CAPS << ":"
#ifdef HAVE_LIBPTHREAD #ifdef HAVE_LIBPTHREAD
<< " +pthreads" << " +pthreads"
#else #else

View file

@ -25,11 +25,14 @@
// //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#define L10N // Localization complete.
#include <fstream> #include <fstream>
#include <sstream> #include <sstream>
#include <Context.h> #include <Context.h>
#include <Uri.h> #include <Uri.h>
#include <Transport.h> #include <Transport.h>
#include <i18n.h>
#include <text.h> #include <text.h>
#include <CmdPull.h> #include <CmdPull.h>
@ -40,7 +43,7 @@ CmdPull::CmdPull ()
{ {
_keyword = "pull"; _keyword = "pull";
_usage = "task pull URL"; _usage = "task pull URL";
_description = "Overwrites the local *.data files with those found at the URL."; _description = STRING_CMD_PULL_USAGE;
_read_only = true; _read_only = true;
_displays_id = false; _displays_id = false;
} }
@ -61,7 +64,7 @@ int CmdPull::execute (std::string& output)
Directory location (context.config.get ("data.location")); Directory location (context.config.get ("data.location"));
if (! uri.append ("{pending,undo,completed}.data")) if (! uri.append ("{pending,undo,completed}.data"))
throw std::string ("The uri '") + uri._path + "' is not a directory. Did you forget a trailing '/'?"; throw format (STRING_CMD_PULL_NOT_DIR, uri._path);
Transport* transport; Transport* transport;
if ((transport = Transport::getTransport (uri)) != NULL) if ((transport = Transport::getTransport (uri)) != NULL)
@ -74,7 +77,7 @@ int CmdPull::execute (std::string& output)
// Verify that files are not being copied from rc.data.location to the // Verify that files are not being copied from rc.data.location to the
// same place. // same place.
if (Directory (uri._path) == Directory (context.config.get ("data.location"))) if (Directory (uri._path) == Directory (context.config.get ("data.location")))
throw std::string ("Cannot pull files when the source and destination are the same."); throw std::string (STRING_CMD_PULL_SAME);
// copy files locally // copy files locally
@ -104,16 +107,14 @@ int CmdPull::execute (std::string& output)
} }
else else
{ {
throw std::string ("At least one of the database files in '" + uri._path + "' is not present."); throw format (STRING_CMD_PULL_MISSING, uri._path);
} }
} }
output += "Tasks transferred from " + uri._data + "\n"; output += format (STRING_CMD_PULL_TRANSFERRED, uri._data) + "\n";
} }
else else
throw std::string ("No uri was specified for the pull. Either specify " throw std::string (STRING_CMD_PULL_NO_URI);
"the uri of a remote .task directory, or create a "
"'pull.default.uri' entry in your .taskrc file.");
return 0; return 0;
} }

View file

@ -25,11 +25,14 @@
// //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#define L10N // Localization complete.
#include <fstream> #include <fstream>
#include <sstream> #include <sstream>
#include <Context.h> #include <Context.h>
#include <Uri.h> #include <Uri.h>
#include <Transport.h> #include <Transport.h>
#include <i18n.h>
#include <text.h> #include <text.h>
#include <CmdPush.h> #include <CmdPush.h>
@ -40,14 +43,14 @@ CmdPush::CmdPush ()
{ {
_keyword = "push"; _keyword = "push";
_usage = "task push URL"; _usage = "task push URL";
_description = "Pushes the local *.data files to the URL."; _description = STRING_CMD_PUSH_USAGE;
_read_only = true; _read_only = true;
_displays_id = false; _displays_id = false;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Transfers the local data (from rc.location._data) to the remote path. Because // Transfers the local data (from rc.location._data) to the remote path.
// this is potentially on another machine, no checking can be performed. // Because this is potentially on another machine, no checking can be performed.
int CmdPush::execute (std::string& output) int CmdPush::execute (std::string& output)
{ {
std::vector <std::string> words = context.a3.extract_words (); std::vector <std::string> words = context.a3.extract_words ();
@ -73,11 +76,11 @@ int CmdPush::execute (std::string& output)
// Verify that files are not being copied from rc.data.location to the // Verify that files are not being copied from rc.data.location to the
// same place. // same place.
if (Directory (uri._path) == Directory (context.config.get ("data.location"))) if (Directory (uri._path) == Directory (context.config.get ("data.location")))
throw std::string ("Cannot push files when the source and destination are the same."); throw std::string (STRING_CMD_PUSH_SAME);
// copy files locally // copy files locally
if (! Path (uri._data).is_directory ()) if (! Path (uri._data).is_directory ())
throw std::string ("The uri '") + uri._path + "' is not a local directory."; throw format (STRING_CMD_PUSH_NONLOCAL, uri._path);
std::ifstream ifile1 ((location._data + "/undo.data").c_str(), std::ios_base::binary); std::ifstream ifile1 ((location._data + "/undo.data").c_str(), std::ios_base::binary);
std::ofstream ofile1 ((uri._path + "/undo.data").c_str(), std::ios_base::binary); std::ofstream ofile1 ((uri._path + "/undo.data").c_str(), std::ios_base::binary);
@ -92,12 +95,10 @@ int CmdPush::execute (std::string& output)
ofile3 << ifile3.rdbuf(); ofile3 << ifile3.rdbuf();
} }
output += "Local tasks transferred to " + uri._data + "\n"; output += format (STRING_CMD_PUSH_TRANSFERRED, uri._data) + "\n";
} }
else else
throw std::string ("No uri was specified for the push. Either specify " throw std::string (STRING_CMD_PUSH_NO_URI);
"the uri of a remote .task directory, or create a "
"'push.default.uri' entry in your .taskrc file.");
return 0; return 0;
} }

View file

@ -25,8 +25,12 @@
// //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#define L10N // Localization complete.
#include <iostream> #include <iostream>
#include <Context.h> #include <Context.h>
#include <text.h>
#include <i18n.h>
#include <CmdSynch.h> #include <CmdSynch.h>
extern Context context; extern Context context;
@ -36,7 +40,7 @@ CmdSynch::CmdSynch ()
{ {
_keyword = "synchronize"; _keyword = "synchronize";
_usage = "task synchronize"; _usage = "task synchronize";
_description = "(Not implemented for 2.0.0beta1)"; _description = STRING_CMD_SYNCH_USAGE;
_read_only = false; _read_only = false;
_displays_id = true; _displays_id = true;
} }
@ -44,6 +48,7 @@ CmdSynch::CmdSynch ()
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
int CmdSynch::execute (std::string& output) int CmdSynch::execute (std::string& output)
{ {
// TODO Tempporary.
std::cout << "\n" std::cout << "\n"
<< "Task Server Synchronization is not implemented in 2.0.0beta1.\n" << "Task Server Synchronization is not implemented in 2.0.0beta1.\n"
<< "\n"; << "\n";

View file

@ -312,6 +312,29 @@
#define STRING_CMD_IMPORT_USAGE "Imports JSON files" #define STRING_CMD_IMPORT_USAGE "Imports JSON files"
#define STRING_CMD_IMPORT_SUMMARY "Imported {1} tasks." #define STRING_CMD_IMPORT_SUMMARY "Imported {1} tasks."
#define STRING_CMD_SHELL_USAGE "Launches an interactive shell" #define STRING_CMD_SHELL_USAGE "Launches an interactive shell"
#define STRING_CMD_SYNCH_USAGE "(Not implemented for 2.0.0beta2)"
#define STRING_CMD_DIAG_USAGE "Shows information needed when reporting a problem."
#define STRING_CMD_DIAG_PLATFORM "Platform"
#define STRING_CMD_DIAG_UNKNOWN "<unknown>"
#define STRING_CMD_DIAG_COMPILER "Compiler"
#define STRING_CMD_DIAG_VERSION "Version"
#define STRING_CMD_DIAG_CAPS "Caps"
#define STRING_CMD_DIAG_LIBRARIES "Libraries"
#define STRING_CMD_DIAG_FEATURES "Build Features"
#define STRING_CMD_DIAG_BUILT "Built"
#define STRING_CMD_DIAG_COMMIT "Commit"
#define STRING_CMD_PUSH_USAGE "Pushes the local *.data files to the URL."
#define STRING_CMD_PUSH_SAME "Cannot push files when the source and destination are the same."
#define STRING_CMD_PUSH_NONLOCAL "The uri '{1}' is not a local directory."
#define STRING_CMD_PUSH_TRANSFERRED "Local tasks transferred to {1}"
#define STRING_CMD_PUSH_NO_URI "No uri was specified for the push. Either specify the uri of a remote .task directory, or create a 'push.default.uri' entry in your .taskrc file."
#define STRING_CMD_PULL_USAGE "Overwrites the local *.data files with those found at the URL."
#define STRING_CMD_PULL_SAME "Cannot pull files when the source and destination are the same."
#define STRING_CMD_PULL_TRANSFERRED "Local tasks transferred from {1}"
#define STRING_CMD_PULL_NO_URI "No uri was specified for the pull. Either specify the uri of a remote .task directory, or create a 'pull.default.uri' entry in your .taskrc file."
#define STRING_CMD_PULL_MISSING "At least one of the database files in '{1}' is not present."
#define STRING_CMD_PULL_NOT_DIR "The uri '{1}' is not a directory. Did you forget a trailing '/'?"
// 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."