#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] : "";
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.
#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"