00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef INCL_SYNC_EVOLUTION_CMDLINE
00021 # define INCL_SYNC_EVOLUTION_CMDLINE
00022
00023 #include "SyncEvolutionConfig.h"
00024 #include "FilterConfigNode.h"
00025 class EvolutionSyncSource;
00026
00027 #include <set>
00028 using namespace std;
00029
00030 #include <boost/shared_ptr.hpp>
00031
00032 class SyncEvolutionCmdlineTest;
00033
00034 class SyncEvolutionCmdline {
00035 public:
00036
00037
00038
00039
00040 SyncEvolutionCmdline(int argc, const char * const *argv, ostream &out, ostream &err);
00041
00042
00043
00044
00045
00046
00047 bool parse();
00048
00049 bool run();
00050
00051 private:
00052 class Bool {
00053 public:
00054 Bool(bool val = false) : m_value(val) {}
00055 operator bool () { return m_value; }
00056 Bool & operator = (bool val) { m_value = val; return *this; }
00057 private:
00058 bool m_value;
00059 };
00060
00061 int m_argc;
00062 const char * const * m_argv;
00063 ostream &m_out, &m_err;
00064
00065 Bool m_quiet;
00066 Bool m_status;
00067 Bool m_version;
00068 Bool m_usage;
00069 Bool m_configure;
00070 Bool m_run;
00071 Bool m_migrate;
00072 Bool m_printServers;
00073 Bool m_printConfig;
00074 Bool m_dontrun;
00075 FilterConfigNode::ConfigFilter m_syncProps, m_sourceProps;
00076 const ConfigPropertyRegistry &m_validSyncProps;
00077 const ConfigPropertyRegistry &m_validSourceProps;
00078
00079 string m_server;
00080 string m_template;
00081 set<string> m_sources;
00082
00083
00084 static string cmdOpt(const char *opt, const char *param = NULL);
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095 bool parseProp(const ConfigPropertyRegistry &validProps,
00096 FilterConfigNode::ConfigFilter &props,
00097 const char *opt,
00098 const char *param,
00099 const char *propname = NULL);
00100
00101 bool listPropValues(const ConfigPropertyRegistry &validProps,
00102 const string &propName,
00103 const string &opt);
00104
00105 bool listProperties(const ConfigPropertyRegistry &validProps,
00106 const string &opt);
00107
00108
00109
00110
00111 void listSources(EvolutionSyncSource &syncSource, const string &header);
00112
00113 void dumpServers(const string &preamble,
00114 const EvolutionSyncConfig::ServerList &servers);
00115
00116 void dumpProperties(const ConfigNode &configuredProps,
00117 const ConfigPropertyRegistry &allProps);
00118
00119 void copyProperties(const ConfigNode &fromProps,
00120 ConfigNode &toProps,
00121 bool hidden,
00122 const ConfigPropertyRegistry &allProps);
00123
00124 void dumpComment(ostream &stream,
00125 const string &prefix,
00126 const string &comment);
00127
00128
00129 void usage(bool full,
00130 const string &error = string(""),
00131 const string ¶m = string(""));
00132
00133 friend class SyncEvolutionCmdlineTest;
00134 };
00135
00136 #endif // INCL_SYNC_EVOLUTION_CMDLINE