]> gitweb.hamatoma.de Git - reqt/commitdiff
dayly work
authorhama <hama@siduction.net>
Thu, 3 Dec 2015 23:03:38 +0000 (00:03 +0100)
committerhama <hama@siduction.net>
Thu, 3 Dec 2015 23:03:38 +0000 (00:03 +0100)
appl/reidos/maincmdline.cpp
base/ReProgramArgs.cpp
base/ReProgramArgs.hpp
base/rebase.hpp

index 38b203cef52a179f073821afba2672fe3f4c42dc..ec98aad385d7502cbed889ffb0c3374e259b6052 100644 (file)
 #include "reidoscmdline.hpp"
 #include <QApplication>
 
+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 <global_opts> sy(nchronize) <options> <source> <target>\n"
+                       "Copies newer and missing files from <source> to <target>\n"
+                       "<source>: the source directory. This directory is never changed\n"
+                       "If <source> ends with the path separator the files of <source> will be copied directly to <target>\n"
+                       "Otherwise the node of <source> will be a subdirectory of <target>\n"
+                       "Examples:\n"
+                       "<source>: /home/ <target>: /trg /home/abc.txt will be copied to /trg/abc.txt\n"
+                       "<source>: /home <target>: /trg /home/abc.txt will be copied to /trg/home/abc.txt"
+                       "<target>: 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 <opts> <mode> <mode_opts> <mode_params>\n"
+               "<mode>:\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] : "";
 
index d978337616f82804bb40763230cf547e572ac1a3..b86cabc470ac79534d50c4f07dc65ef0c50beb5d 100644 (file)
@@ -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 <code>'\\n'</code> for separate lines
+ * @param examples     a string with one ore more calling examples.
+ *                                     It may contain <code>'\\n'</code> 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.
index ba703108d09e96efea7ddf5e1763336d7321afe3..0890f202e70942f8e94e6743c2e94283ba5d4149 100644 (file)
@@ -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,
index ae366b515d7a869873f858ff88fbc1d8c2132d98..5b61dd6318a2e6a558b58c536c7b36f6a9d6b9f4 100644 (file)
@@ -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"