From: hama Date: Thu, 3 Dec 2015 23:03:38 +0000 (+0100) Subject: dayly work X-Git-Url: https://gitweb.hamatoma.de/?a=commitdiff_plain;h=2a42358d1448952ac59d65c3b30960bab836bd29;p=reqt dayly work --- diff --git a/appl/reidos/maincmdline.cpp b/appl/reidos/maincmdline.cpp index 38b203c..ec98aad 100644 --- a/appl/reidos/maincmdline.cpp +++ b/appl/reidos/maincmdline.cpp @@ -10,9 +10,69 @@ #include "reidoscmdline.hpp" #include +class SyncHandler{ +public: + SyncHandler(ReProgramArgs* globalArgs); +private: + ReProgramArgs* m_globalArgs; + ReProgramArgs* m_syncArgs; +}; +/** + * Constructor. + * + * @param globalArgs the global arguments (useful for all modes) + */ +SyncHandler::SyncHandler(ReProgramArgs* globalArgs) : + m_globalArgs(globalArgs), + m_syncArgs(NULL){ + m_syncArgs = new ReProgramArgs( + I18N::s2b(QObject::tr( + "usage: $0 sy(nchronize) \n" + "Copies newer and missing files from to \n" + ": the source directory. This directory is never changed\n" + "If ends with the path separator the files of will be copied directly to \n" + "Otherwise the node of will be a subdirectory of \n" + "Examples:\n" + ": /home/ : /trg /home/abc.txt will be copied to /trg/abc.txt\n" + ": /home : /trg /home/abc.txt will be copied to /trg/home/abc.txt" + ": the target directory" + )), + "$0 sy -p *,*.txt,*.odt --dir-patterns=*,.git,.* /home /backup\n" + "$0 sync --file-pattern=*,-*.bak,-*~ -P *,-*cache* /work crypt:/media/nas" + ); + m_syncArgs->addString("filePattern", I18N::s2b(QObject::tr( + "a comma separated list of file patterns to include/exclude files to copy.\n" + "An exclude pattern begins with '-'. Placeholder is '*' (for any string)\n" + "Examples:\n" + "--file-pattern=*,-*.bak\n" + "-p *.txt,*.doc,*.odt")), + 'p', "file-pattern", false, "*"); + m_syncArgs->addString("dirPattern", I18N::s2b(QObject::tr( + "a comma separated list of directory patterns to include/exclude directories from processing.\n" + "An exclude pattern begins with '-'. Placeholder is '*' (for any string)\n" + "Examples:\n" + "--dir-pattern=;*;-.cache\n" + "-P *,-.git,.*")), + 'P', "dir-pattern", false, "*"); +} + int main(int argc, char *argv[]) { QApplication a(argc, argv); + ReProgramArgs args( + QObject::tr( + "Usage: $0 \n" + ":\n" + "co(mpare) compares two directories\n" + "sm(ooth) superflous files on target will be removed\n" + "sy(nchronize) newer or missing files will be copied from source to target" + ), + QObject::tr( + "reidoscmdline help sync\n" + "reidoscmdline -v sync --dir-pattern=;*;-cache --file-pattern=;*.txt;*.doc /x /y" + )); + + QString startDir = argc > 1 ? argv[1] : ""; QString homeDir = argc > 2 ? argv[2] : ""; diff --git a/base/ReProgramArgs.cpp b/base/ReProgramArgs.cpp index d978337..b86cabc 100644 --- a/base/ReProgramArgs.cpp +++ b/base/ReProgramArgs.cpp @@ -105,7 +105,27 @@ ReProgramArgs::ReProgramArgs(const char* usageString, const char* examples) : line.replace("$0", m_program); m_examples = line.split('\n'); } + } +} +/** @brief Constructor. + * + * @param usage a string with the description of the usage + * It may contain '\\n' for separate lines + * @param examples a string with one ore more calling examples. + * It may contain '\\n' for separate lines + */ +ReProgramArgs::ReProgramArgs(const QString& usageString, QString examples) : + m_usage(), + m_examples(), + m_options(), + m_args(NULL), + m_argCount(0), + m_program("?"), + m_lastError() { + m_usage = I18N::s2b(usageString).split('\n'); + if (! examples.isEmpty()) { + m_examples = I18N::s2b(examples.replace("$0", QString(m_program))).split('\n'); } } /** @brief Destructor. diff --git a/base/ReProgramArgs.hpp b/base/ReProgramArgs.hpp index ba70310..0890f20 100644 --- a/base/ReProgramArgs.hpp +++ b/base/ReProgramArgs.hpp @@ -58,6 +58,8 @@ public: public: ReProgramArgs(const char* usageList[], const char* examples[] = NULL); ReProgramArgs(const char* usageString, const char* examples = NULL); + ReProgramArgs(const QString& usageString, + QString examples = ReQStringUtils::m_empty); virtual ~ReProgramArgs(); public: void addBool(const char* name, const char* description, char shortOpt, diff --git a/base/rebase.hpp b/base/rebase.hpp index ae366b5..5b61dd6 100644 --- a/base/rebase.hpp +++ b/base/rebase.hpp @@ -158,10 +158,10 @@ inline int roundInt(double value) { #include "base/ReWriter.hpp" #include "base/ReLogger.hpp" #include "base/ReException.hpp" -#include "base/ReProgramArgs.hpp" #include "base/ReContainer.hpp" #include "base/ReStringUtils.hpp" #include "base/ReQStringUtils.hpp" +#include "base/ReProgramArgs.hpp" #include "base/ReConfigurator.hpp" #include "base/ReConfig.hpp" #include "base/ReTerminator.hpp"