tool/main.cpp
changeset 2042 8b358effa78b
parent 2011 04fdb4abf120
child 2436 960cc1bb6b4a
child 2589 2b9c78543663
equal deleted inserted replaced
2041:f5b31f46c38f 2042:8b358effa78b
    75 string commandName;
    75 string commandName;
    76 Command::StringVector commandArgs;
    76 Command::StringVector commandArgs;
    77 
    77 
    78 // option variables
    78 // option variables
    79 string masters = "-"; // all masters
    79 string masters = "-"; // all masters
    80 int slavePosition = -1;
    80 string positions = "-"; // all positions
    81 int slaveAlias = -1;
    81 string aliases = "-"; // all aliases
    82 int domainIndex = -1;
    82 string domains = "-"; // all domains
    83 string dataTypeStr;
    83 string dataTypeStr;
    84 Command::Verbosity verbosity = Command::Normal;
    84 Command::Verbosity verbosity = Command::Normal;
    85 bool force = false;
    85 bool force = false;
    86 bool helpRequested = false;
    86 bool helpRequested = false;
    87 string outputFile;
    87 string outputFile;
   161             case 'm':
   161             case 'm':
   162                 masters = optarg;
   162                 masters = optarg;
   163                 break;
   163                 break;
   164 
   164 
   165             case 'a':
   165             case 'a':
   166                 str.clear();
   166                 aliases = optarg;
   167                 str.str("");
       
   168                 str << optarg;
       
   169                 str >> resetiosflags(ios::basefield) // guess base from prefix
       
   170                     >> slaveAlias;
       
   171                 if (str.fail() || slaveAlias < 0 || slaveAlias > 0xFFFF) {
       
   172                     cerr << "Invalid slave alias " << optarg << "!" << endl
       
   173                         << endl << usage();
       
   174                     exit(1);
       
   175                 }
       
   176                 break;
   167                 break;
   177 
   168 
   178             case 'p':
   169             case 'p':
   179                 str.clear();
   170                 positions = optarg;
   180                 str.str("");
       
   181                 str << optarg;
       
   182                 str >> resetiosflags(ios::basefield) // guess base from prefix
       
   183                     >> slavePosition;
       
   184                 if (str.fail()
       
   185                         || slavePosition < 0 || slavePosition > 0xFFFF) {
       
   186                     cerr << "Invalid slave position " << optarg << "!" << endl
       
   187                         << endl << usage();
       
   188                     exit(1);
       
   189                 }
       
   190                 break;
   171                 break;
   191 
   172 
   192             case 'd':
   173             case 'd':
   193                 str.clear();
   174                 domains = optarg;
   194                 str.str("");
       
   195                 str << optarg;
       
   196                 str >> resetiosflags(ios::basefield) // guess base from prefix
       
   197                     >> domainIndex;
       
   198                 if (str.fail() || domainIndex < 0) {
       
   199                     cerr << "Invalid domain index " << optarg << "!" << endl
       
   200                         << endl << usage();
       
   201                     exit(1);
       
   202                 }
       
   203                 break;
   175                 break;
   204 
   176 
   205             case 't':
   177             case 't':
   206                 dataTypeStr = optarg;
   178                 dataTypeStr = optarg;
   207                 break;
   179                 break;
   329             cmd = matchingCommands.front();
   301             cmd = matchingCommands.front();
   330             if (!helpRequested) {
   302             if (!helpRequested) {
   331                 try {
   303                 try {
   332                     cmd->setMasters(masters);
   304                     cmd->setMasters(masters);
   333                     cmd->setVerbosity(verbosity);
   305                     cmd->setVerbosity(verbosity);
   334                     cmd->setAlias(slaveAlias);
   306                     cmd->setAliases(aliases);
   335                     cmd->setPosition(slavePosition);
   307                     cmd->setPositions(positions);
   336                     cmd->setDomain(domainIndex);
   308                     cmd->setDomains(domains);
   337                     cmd->setDataType(dataTypeStr);
   309                     cmd->setDataType(dataTypeStr);
   338                     cmd->setOutputFile(outputFile);
   310                     cmd->setOutputFile(outputFile);
   339                     cmd->setForce(force);
   311                     cmd->setForce(force);
   340                     cmd->execute(commandArgs);
   312                     cmd->execute(commandArgs);
   341                 } catch (InvalidUsageException &e) {
   313                 } catch (InvalidUsageException &e) {