static void handleHelpOption() { // Register all program options in the command line interpreter util::cmdline::interpreter<std::string> cli; BaseOption::registerAll(cli); showCommandLineHelp(cli, std::cout); std::exit(EXIT_SUCCESS); }
void Master::processCommandLine(QStringList args) { int argIx = 1; QString command = args.at(argIx++); while (command.startsWith('-')) { if (QString::compare(command, "-profile", Qt::CaseInsensitive) == 0) { if (args.count() > argIx) { QString profile = args.at(argIx++); if (enumSynthProfiles().contains(profile, Qt::CaseInsensitive)) { synthProfileName = profile; } else { QMessageBox::warning(NULL, "Error", "The profile name specified in command line is invalid.\nOption \"-profile\" ignored."); } } else { QMessageBox::warning(NULL, "Error", "The profile name must be specified in command line with \"-profile\" option."); showCommandLineHelp(); } } else if (QString::compare(command, "-max_sessions", Qt::CaseInsensitive) == 0) { if (args.count() > argIx) { maxSessions = args.at(argIx++).toUInt(); if (maxSessions == 0) QMessageBox::warning(NULL, "Error", "The maximum number of sessions specified in command line is invalid.\nOption \"-max_sessions\" ignored."); } else { QMessageBox::warning(NULL, "Error", "The maximum number of sessions must be specified in command line with \"-max_sessions\" option."); showCommandLineHelp(); } } else { QMessageBox::warning(NULL, "Error", "Illegal command line option " + command + " specified."); showCommandLineHelp(); } if (args.count() == argIx) return; command = args.at(argIx++); } if (args.count() == argIx) { QMessageBox::warning(NULL, "Error", "The file list must be specified in command line with a command."); showCommandLineHelp(); return; } QStringList files = args.mid(argIx); if (QString::compare(command, "play", Qt::CaseInsensitive) == 0) { emit playMidiFiles(files); } else if (QString::compare(command, "convert", Qt::CaseInsensitive) == 0) { if (args.count() > (argIx + 1)) { emit convertMidiFiles(files); } else { QMessageBox::warning(NULL, "Error", "The file list must be specified in command line with " + command + " command."); showCommandLineHelp(); } } else { QMessageBox::warning(NULL, "Error", "Illegal command " + command + " specified in command line."); showCommandLineHelp(); } }
static ExitStatus parseCommandLine(int argc, char ** argv) { platform::initializeEnvironment(argv[0]); // Register all program options in the command line interpreter util::cmdline::interpreter<std::string> cli; BaseOption::registerAll(cli); try { util::cmdline::parse(cli, argc, argv); } catch(util::cmdline::error & e) { std::cerr << e.what() << "\n\n"; showCommandLineHelp(cli, std::cerr); return ExitFailure; } return RunProgram; }