QString checkForInvalidImageOptions(QStringList arguments) { QString error = checkOptionForInt("--height", &arguments, 1, 32767); if (error.length() > 0) return error; error = checkOptionForInt("--width", &arguments, 1, 32767); if (error.length() > 0) return error; return checkForInvalidOrExcessSettings(&arguments); }
int main(int argc, char *argv[]) { QApplication a(argc, argv); QApplication::setApplicationName("Bandage"); QApplication::setApplicationVersion("0.6.2"); QTextStream out(stdout); QTextStream err(stdout); //Create the important global objects. g_settings.reset(new Settings()); g_blastSearch.reset(new BlastSearch()); g_assemblyGraph.reset(new AssemblyGraph()); g_graphicsView = new MyGraphicsView(); QStringList arguments = QCoreApplication::arguments(); arguments.pop_front(); if (checkForVersion(arguments)) { out << "Version: " << QApplication::applicationVersion() << endl; return 0; } //If the first argument was a recognised command, move to that command's function. if (arguments.size() > 0) { QString first = arguments.at(0); if (first == "load") { arguments.pop_front(); g_settings->commandLineCommand = BANDAGE_LOAD; return bandageLoad(&a, arguments); } else if (first == "image") { arguments.pop_front(); g_settings->commandLineCommand = BANDAGE_IMAGE; return bandageImage(arguments); } // else if (first == "contiguous") // { // arguments.pop_front(); // return bandageContiguous(arguments); // } } //Since a recognised command was not seen, we now check to see if the user //was looking for help information. if (checkForHelp(arguments)) { out << "" << endl; out << "Program: Bandage" << endl; out << "Version: " << QApplication::applicationVersion() << endl; printUsage(&out, false); return 0; } if (checkForHelpAll(arguments)) { out << "" << endl; out << "Program: Bandage" << endl; out << "Version: " << QApplication::applicationVersion() << endl; printUsage(&out, true); return 0; } //If the code got here, we assume the user is simply launching Bandage, //with or without some options to specify settings. //Check the settings. QStringList argumentsCopy = arguments; QString error = checkForInvalidOrExcessSettings(&argumentsCopy); if (error.length() > 0) { err << "Bandage error: " + error << endl; return 1; } //If the code got here, then the settings are good. Parse them now and //run the program. parseSettings(arguments); MainWindow w; w.show(); return a.exec(); }