| 113 | } |
| 114 | |
| 115 | Strategy* Application::parseArguments(int argc,char* argv[]) |
| 116 | { |
| 117 | const QStringList& arguments=getArguments(argc,argv); |
| 118 | |
| 119 | QCommandLineParser p; |
| 120 | p.setApplicationDescription(QCoreApplication::translate("main","RapCAD the rapid prototyping IDE")); |
| 121 | p.addHelpOption(); |
| 122 | p.addVersionOption(); |
| 123 | p.addPositionalArgument("filename", QCoreApplication::translate("main","File to open or process.")); |
| 124 | |
| 125 | #ifdef USE_INTEGTEST |
| 126 | QCommandLineOption testOption(QStringList() << "t" << "test", QCoreApplication::translate("main","Run through tests in working directory."),"directory"); |
| 127 | p.addOption(testOption); |
| 128 | |
| 129 | QCommandLineOption generateOption(QStringList() << "g" << "generate", QCoreApplication::translate("main","Generate documentation")); |
| 130 | p.addOption(generateOption); |
| 131 | #endif |
| 132 | |
| 133 | QCommandLineOption compareOption(QStringList() << "c" << "compare", QCoreApplication::translate("main","Compare two files to see if they are identical."),"filename"); |
| 134 | p.addOption(compareOption); |
| 135 | |
| 136 | QCommandLineOption outputOption(QStringList() << "o" << "output",QCoreApplication::translate("main","Create output file <filename>."),"filename"); |
| 137 | p.addOption(outputOption); |
| 138 | |
| 139 | QCommandLineOption redirectOption(QStringList() << "r" << "redirect",QCoreApplication::translate("main","Redirect output to file <filename>."),"filename"); |
| 140 | p.addOption(redirectOption); |
| 141 | |
| 142 | #ifdef USE_READLINE |
| 143 | QCommandLineOption interactOption(QStringList() << "i" << "interactive",QCoreApplication::translate("main","Start an interactive session")); |
| 144 | p.addOption(interactOption); |
| 145 | #endif |
| 146 | |
| 147 | // Work around for Qt dependency |
| 148 | // on QCoreApplication in showHelp |
| 149 | if(!p.parse(arguments)) { |
| 150 | p.process(arguments); // exits |
| 151 | } else { |
| 152 | if(p.isSet("help")) { |
| 153 | QCoreApplication a(argc,argv); |
| 154 | p.showHelp(); // exits |
| 155 | } else if(p.isSet("version")) { |
| 156 | p.showVersion(); // exits |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | if(p.isSet(redirectOption)) { |
| 161 | redirectFile=new QFile(p.value(redirectOption)); |
| 162 | if(redirectFile->open(QFile::WriteOnly)) |
| 163 | reporter.output.setDevice(redirectFile); |
| 164 | } |
| 165 | |
| 166 | inputFiles=p.positionalArguments(); |
| 167 | QString inputFile; |
| 168 | if(!inputFiles.isEmpty()) { |
| 169 | inputFile=inputFiles.at(0); |
| 170 | } |
| 171 | |
| 172 | if(p.isSet(compareOption)) { |
nothing calls this directly
no test coverage detected