当前位置: 首页>>代码示例>>C++>>正文


C++ QCommandLineParser::addPositionalArgument方法代码示例

本文整理汇总了C++中QCommandLineParser::addPositionalArgument方法的典型用法代码示例。如果您正苦于以下问题:C++ QCommandLineParser::addPositionalArgument方法的具体用法?C++ QCommandLineParser::addPositionalArgument怎么用?C++ QCommandLineParser::addPositionalArgument使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QCommandLineParser的用法示例。


在下文中一共展示了QCommandLineParser::addPositionalArgument方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: commandLineArgumentsValid

bool commandLineArgumentsValid(QStringList *positionalArgs,
                               QStringList *ignoreMasks)
{
  bool result = true;

  QCommandLineParser parser;
  parser.setApplicationDescription("Creates patches");
  parser.addHelpOption();
  parser.addVersionOption();
  parser.addPositionalArgument("old",     QCoreApplication::translate("main", "Path to a directory containing old version of files"));
  parser.addPositionalArgument("new",     QCoreApplication::translate("main", "Path to a directory containing new version of files"));
  parser.addPositionalArgument("result",  QCoreApplication::translate("main", "Path to a directory where resulting patch will be stored"));

  QCommandLineOption ignoreOption(QStringList() << "i" << "ignore",
                                  QCoreApplication::translate("main", "Specifies which file or folder to ignore during comparison. Can be used multiple times. e.g. -i .svn -i *.txt"),
                                  QCoreApplication::translate("main", "mask"));
  parser.addOption(ignoreOption);

  // Process the actual command line arguments given by the user
  parser.process(*qApp);

  *positionalArgs = parser.positionalArguments();
  if (positionalArgs->size() < 3)
  {
    fputs(qPrintable(parser.helpText()), stderr);
    result = false;
  }

  *ignoreMasks = parser.values(ignoreOption);

  return result;
}
开发者ID:geotavros,项目名称:PatchMaker,代码行数:32,代码来源:main.cpp

示例2: main

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
    QCoreApplication::setApplicationName("armadill");
    QCoreApplication::setApplicationVersion("0.1");

    QCommandLineParser parser;

    parser.setApplicationDescription("armadill- super secure IM");

    parser.addPositionalArgument("server", "Server ip to connect to");
    parser.addPositionalArgument("port", "port of that server");
    parser.addHelpOption();

    QCommandLineOption test(QStringList() << "t" << "test", "Run tests");
    parser.addOption(test);

    parser.process(a);

    if(parser.isSet(test))
    {
        UTest test;
        return test.makeTests(argc, argv);
    }

    //parse things, run test if test
	QTextStream out(stdout);
    ClientConsole n(parser.positionalArguments(), out, &a);
    QMetaObject::invokeMethod(&n, "init", Qt::QueuedConnection);

    return a.exec();
}
开发者ID:santomet,项目名称:armadill,代码行数:32,代码来源:client.cpp

示例3: main

int main(int argc, char **argv) {
	QApplication app(argc, argv);
	QApplication::setApplicationName("ViewDown");
	QApplication::setApplicationVersion("1.0");
	app.setWindowIcon(QIcon("qrc:///viewdown.ico"));

	QCommandLineParser parser;
	parser.setApplicationDescription("Markdown viewer, reloading on changes.");
	parser.addPositionalArgument("file", "markdown file to view and reload on change.");
	parser.addPositionalArgument("watch", "files or directories to watch as trigger for reload.", "[watch...]");
	const QCommandLineOption styleOption("s", "css file to use as stylesheet.", "css");
	parser.addOption(styleOption);
	parser.addHelpOption();
	parser.addVersionOption();

	parser.process(app);

	QUrl styleUrl;
	if (parser.isSet(styleOption)) {
		const QString path = parser.value(styleOption);
		QFileInfo info = QFileInfo(path);
		if (info.exists())
		        styleUrl = QUrl::fromLocalFile(info.canonicalFilePath());
		else
			qWarning("No such file: %s", qPrintable(path));
	}
	if (styleUrl.isEmpty())
		styleUrl = QUrl("qrc:///github.css");

	MainWindow *browser = new MainWindow(parser.positionalArguments(), styleUrl);
	browser->show();
	return app.exec();
}
开发者ID:Cornu,项目名称:viewdown,代码行数:33,代码来源:main.cpp

示例4: createInputCommands

//! Bereitet die Eingabeparameter vor
void createInputCommands(QCommandLineParser &cmdParser) {
  //! Befehle
  QCommandLineOption inputPath("i", "Path for input", "...");
  QCommandLineOption outputPath("o", "Path for output", "...");
  QCommandLineOption generateType("g", "Generating type", "[htmlbasic]");
  QCommandLineOption chartTitle("t", "Title for the chart", "...");
  QCommandLineOption minValueX("x", "Maximumvalue for the chart on the X-Axis", "...");
  QCommandLineOption minValueY("y", "Maximumvalue for the chart on the Y-Axis", "...");

  cmdParser.setApplicationDescription("Description");
  cmdParser.addHelpOption();
  cmdParser.addPositionalArgument("useLabel",
                                  "Use the label form json as label for the graph");
  cmdParser.addPositionalArgument("useScrolling", "Uses Scrolling with Highstock");
  cmdParser.addPositionalArgument("useInlineJS",
                                  "Uses JQuery and HighChart without seperate File");
  cmdParser.addPositionalArgument("useNavigator", "Adds a navigator to the chart");

  //! Optionen hinzufügen
  cmdParser.addOption(inputPath);
  cmdParser.addOption(outputPath);
  cmdParser.addOption(generateType);
  cmdParser.addOption(chartTitle);
  cmdParser.addOption(minValueX);
  cmdParser.addOption(minValueY);
}
开发者ID:LepelTsmok,项目名称:GoogleBench2HighChart,代码行数:27,代码来源:Commandline.cpp

示例5: setupCommandLineParser

void setupCommandLineParser(QCommandLineParser& parser)
{
    parser.setApplicationDescription("Command line tool to validate 1-n XML files against a given schema.");
    parser.addHelpOption();
    parser.addVersionOption();
    parser.addPositionalArgument("schemaFile", "The path to the schema file.");
    parser.addPositionalArgument("xmlFile", "The path to an .xml file");
}
开发者ID:Blubbz0r,项目名称:XmlSchemaValidator,代码行数:8,代码来源:main.cpp

示例6: main

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    QCoreApplication app(argc, argv);
    QCoreApplication::setApplicationName("evnav-cli");
    QCoreApplication::setApplicationVersion("0.1");

    QCommandLineParser parser;
    parser.setApplicationDescription("electric vehicule trip planner");
    parser.addHelpOption();
    parser.addVersionOption();
    parser.addPositionalArgument("osrm", "path to osrm file");
    parser.addPositionalArgument("charger", "path to json charger file");

    parser.process(app);
    const QStringList args = parser.positionalArguments();

    if (args.size() < 2) {
        qDebug() << "missing arguments";
        parser.showHelp(1);
    }

    qDebug() << "loading street data...";
    Evnav evnav(args.at(0));

    qDebug() << "loading chargers...";
    ChargerProvider provider;
    provider.loadJson(args.at(1));
    ChargerProvider dcfc = provider.filter(provider.fastChargerFilter());
    qDebug() << "fast chargers found:" << dcfc.size();

    evnav.setChargerProvider(&dcfc);
    evnav.initGraph();

    HttpServer httpd;
    EvnavServer handler;
    handler.setEngine(&evnav);

    HttpServerRequestRouter router {
        { QRegularExpression{"^/route/v1/evnav/.*"}, handler },
        { QRegularExpression{",*"}, NotFoundHandler::handler() },
    };

    QObject::connect(&httpd, &HttpServer::requestReady,
        &router, &HttpServerRequestRouter::handleRequest);

    httpd.listen(QHostAddress::Any, 8080);

    return a.exec();
}
开发者ID:hexa00,项目名称:evnav,代码行数:51,代码来源:main.cpp

示例7: main

int main(int argc, char *argv[])
{
   QCoreApplication app(argc, argv);
   QCoreApplication::setApplicationName("Find_books");
   QCoreApplication::setApplicationVersion("1.0");

   QCommandLineParser parser;
   parser.addHelpOption();
   parser.addVersionOption();
   parser.setApplicationDescription(QCoreApplication::translate("main","Find books from Gornica.ru."));


   parser.addPositionalArgument("s_file", QCoreApplication::translate("main", "Source file from read."));
   parser.addPositionalArgument("t_delay", QCoreApplication::translate("main", "Delay time."));

   parser.process(app);

   QList<QString> args = parser.positionalArguments();

   d_time=0;


#ifdef Q_OS_WIN32
   QTextCodec::setCodecForLocale(QTextCodec::codecForName("IBM 866"));
#endif

#ifdef Q_OS_LINUX
   QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));
#endif
   //QTextStream Qcout(stdout);

   downloader = new Downloader(); // Инициализируем Downloader

   if (((args.size() < 1))) {
      printf("%s\n", qPrintable(QCoreApplication::translate("main", "Error: Must specify one filename argument.")));
      parser.showHelp(1);
   }
   else
   {

      m_File.append(args.value(0));
      d_time = args.value(1,"8000").toInt();
      m_CreateLists(m_File);
   }

   qDebug()  <<m_File;

   m_ReadF();
   app.exit();
}
开发者ID:PrivalovN,项目名称:FindBook,代码行数:50,代码来源:main.cpp

示例8: main

int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);
    app.setApplicationName(QStringLiteral("kiconfinder"));
    app.setApplicationVersion(KICONTHEMES_VERSION_STRING);
    QCommandLineParser parser;
    parser.setApplicationDescription(app.translate("main", "Finds an icon based on its name"));
    parser.addPositionalArgument(QStringLiteral("iconname"), app.translate("main", "The icon name to look for"));
    parser.addHelpOption();

    parser.process(app);
    if(parser.positionalArguments().isEmpty())
        parser.showHelp();

    Q_FOREACH(const QString& iconName, parser.positionalArguments()) {
        const QString icon = KIconLoader::global()->iconPath(iconName, KIconLoader::Desktop /*TODO configurable*/, true);
        if ( !icon.isEmpty() ) {
            printf("%s\n", icon.toLocal8Bit().constData());
        } else {
            return 1; // error
        }
    }

    return 0;
}
开发者ID:KDE,项目名称:kiconthemes,代码行数:25,代码来源:kiconfinder.cpp

示例9: main

int main(int argc, char *argv[])
{
    QCoreApplication app(argc, argv);

    // some command line arguments parsing stuff
    QCoreApplication::setApplicationName("ujea");
    QCoreApplication::setApplicationVersion("1.2");

    QString hostname = QHostInfo::localHostName();

    QCommandLineParser parser;
    parser.setApplicationDescription("Universal job execution agent using AMQP queue");
    parser.addHelpOption();
    parser.addVersionOption();
    parser.addOption(QCommandLineOption("aliveInterval", "Interval in ms between alive messages (1000).", "aliveInterval", "1000"));
    parser.addOption(QCommandLineOption("aliveTTL", "TTL in queue for alive messages (1500).", "aliveTTL", "1500"));
    parser.addOption(QCommandLineOption("queueCmd", "Commands queue name ("+hostname+"_cmd).", "queueCmd", hostname+"_cmd"));
    parser.addOption(QCommandLineOption("queueRpl", "Replays queue name ("+hostname+"_rpl).", "queueRpl", hostname+"_rpl"));
    parser.addOption(QCommandLineOption("execRegex", "Regex for permited commands. (none)", "execRegex", ""));
    parser.addPositionalArgument("url", QCoreApplication::translate("main", "AMQP url"));
    parser.process(app);

    const QStringList args = parser.positionalArguments();

    // we need to have 1 argument and optional named arguments
    if (args.count() != 1) parser.showHelp(-1);

    // create and execure worker
    JobsExecuter qw{QUrl(args.value(0)), parser.value("queueCmd"), parser.value("queueRpl"),
                    parser.value("aliveInterval").toInt(), parser.value("aliveTTL").toInt(),
                    parser.value("execRegex")};

    return app.exec();
}
开发者ID:kanocz,项目名称:ujea,代码行数:34,代码来源:main.cpp

示例10: main

int main(int argc, char **argv)
{
    PrintQueue app(argc, argv);
    app.setOrganizationDomain("org.kde");

    KAboutData about("PrintQueue",
                     i18n("Print Queue"),
                     PM_VERSION,
                     i18n("Print Queue"),
                     KAboutLicense::GPL,
                     i18n("(C) 2010-2013 Daniel Nicoletti"));

    about.addAuthor(QStringLiteral("Daniel Nicoletti"), QString(), "[email protected]");
    about.addAuthor(QStringLiteral("Lukáš Tinkl"), i18n("Port to Qt 5 / Plasma 5"), QStringLiteral("[email protected]"));

    KAboutData::setApplicationData(about);
    KDBusService service(KDBusService::Unique);

    QCommandLineParser parser;
    about.setupCommandLine(&parser);
    parser.addVersionOption();
    parser.addHelpOption();
    parser.addPositionalArgument("queue", i18n("Show printer queue(s)"));
    parser.process(app);
    about.processCommandLine(&parser);

    QObject::connect(&service, &KDBusService::activateRequested, &app, &PrintQueue::showQueues);

    app.showQueues(parser.positionalArguments());

    return app.exec();
}
开发者ID:KDE,项目名称:print-manager,代码行数:32,代码来源:main.cpp

示例11: main

int main(int argc, char** argv)
{
    QApplication app(argc, argv);
    app.setApplicationName(QLatin1String("ThumbNailer"));
    app.setOrganizationDomain(QLatin1String("kde.org"));
    QCommandLineParser parser;
    parser.setApplicationDescription(app.translate("main", "ThreadWeaver ThumbNailer Example"));
    parser.addHelpOption();
    parser.addPositionalArgument(QLatin1String("mode"), QLatin1String("Benchmark or demo mode"));
    parser.process(app);
    const QStringList positionals = parser.positionalArguments();
    const QString mode = positionals.isEmpty() ? QLatin1String("demo") : positionals[0];
    if (mode == QLatin1String("benchmark")) {
        Benchmark benchmark;
        const QStringList arguments = app.arguments().mid(1); // remove mode selection
        return QTest::qExec(&benchmark, arguments);
    } else if (mode == QLatin1String("demo")){
        // demo mode
        MainWindow mainWindow;
        mainWindow.show();
        return app.exec();
    } else {
        wcerr << "Unknown mode " << mode.toStdWString() << endl << endl;
        parser.showHelp();
        Q_UNREACHABLE();
    }
    return 0;
}
开发者ID:liyubo3603237,项目名称:threadweaver,代码行数:28,代码来源:ThumbNailer.cpp

示例12: parseCommandLine

void parseCommandLine(QCoreApplication &app, CmdLineOptions *opts)
{
    QCommandLineParser parser;

    parser.setApplicationDescription("remove db key at specified path");
    parser.addHelpOption();
    parser.addVersionOption();

    parser.addPositionalArgument("key", QCoreApplication::translate("main", "key"));

    QCommandLineOption debugOption(QStringList() << "d" << "debug",
                                   QCoreApplication::translate("main", "enable debug/verbose logging"));
    parser.addOption(debugOption);

    parser.process(app);

    opts->debuggingEnabled = parser.isSet(debugOption);

    const QStringList posArgs = parser.positionalArguments();
    if (posArgs.size() < 1)
    {
        qCritical("invalid arguments");
        exit(1);
    }

    opts->key = posArgs.at(0);

    DbdLogging::logger()->debugMode =  opts->debuggingEnabled;

    qDebug() << "debugging enabled:" << opts->debuggingEnabled;
    qDebug() << "key:" << opts->key;
}
开发者ID:cjp256,项目名称:qtdbd,代码行数:32,代码来源:main.cpp

示例13: main

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    a.setApplicationName(TARGET);
    a.setApplicationVersion("1");
#ifdef __linux__
    a.setWindowIcon(QIcon(":MoleGraph.png"));
#endif

    QCommandLineParser parser;
    parser.setApplicationDescription("Test helper");
    parser.addHelpOption();
    parser.addVersionOption();

    QCommandLineOption openOption(QStringList() << "o" << "open-file",
                QCoreApplication::translate("main", "Open file."), QCoreApplication::translate("main", "directory"));
    parser.addOption(openOption);

    QCommandLineOption withoutValuesOption(QStringList() << "w" << "without-values",
                QCoreApplication::translate("main", "Modifier for opening file without values (just measurement template)."));
    parser.addOption(withoutValuesOption);

    parser.addPositionalArgument("file", "file to open");

    parser.process(a);

    QString fileName = parser.value(openOption);
    const QStringList arguments = parser.positionalArguments();
    if (arguments.size() > 0)
        fileName = arguments[0];
    MainWindow w(a, fileName, parser.isSet(withoutValuesOption));
    w.show();

	return a.exec();
}
开发者ID:e-Mole,项目名称:MoleGraph,代码行数:35,代码来源:main.cpp

示例14: parse

void ApplicationSettings::parse()
{
    QCommandLineParser parser;
    parser.setApplicationDescription(QObject::tr("i-score - An interactive sequencer for the intermedia arts."));
    parser.addHelpOption();
    parser.addVersionOption();
    parser.addPositionalArgument("file", QCoreApplication::translate("main", "Scenario to load."));

    QCommandLineOption noGUI("no-gui", QCoreApplication::translate("main", "Disable GUI"));
    parser.addOption(noGUI);
    QCommandLineOption noRestore("no-restore", QCoreApplication::translate("main", "Disable auto-restore"));
    parser.addOption(noRestore);

    QCommandLineOption autoplayOpt("autoplay", QCoreApplication::translate("main", "Auto-play the loaded scenario"));
    parser.addOption(autoplayOpt);

    parser.process(*qApp);

    const QStringList args = parser.positionalArguments();

    tryToRestore = !parser.isSet(noRestore);
    gui = !parser.isSet(noGUI);
    autoplay = parser.isSet(autoplayOpt) && args.size() == 1;

    if(!args.empty() && QFile::exists(args[0]))
    {
        loadList.push_back(args[0]);
    }
}
开发者ID:himito,项目名称:i-score,代码行数:29,代码来源:ApplicationSettings.cpp

示例15: main

int main(int argc, char * argv[])
{
    QApplication app(argc, argv);

    QCommandLineParser commandLineParser;
    commandLineParser.addPositionalArgument(QStringLiteral("url"),
        QStringLiteral("The url to be loaded in the browser window."));
    commandLineParser.process(app);
    QStringList positionalArguments = commandLineParser.positionalArguments();

    QUrl url;
    QString year,month,outputPath;
    int day;
    if (positionalArguments.size() > 5) {
        showHelp(commandLineParser, QStringLiteral("Too many arguments."));
        return -1;
    } else if (positionalArguments.size() == 5) {
        url = QUrl::fromUserInput(positionalArguments.at(0));
        year = positionalArguments.at(1);
        month = positionalArguments.at(2);
        day = positionalArguments.at(3).toInt();
        outputPath = positionalArguments.at(4);
    }
    else
        url = QUrl("http://query.nytimes.com/search/sitesearch/#/crude+oil/from20100502to20100602/allresults/1/allauthors/relevance/business");

    if (!url.isValid()) {
        showHelp(commandLineParser, QString("%1 is not a valid url.").arg(positionalArguments.at(0)));
        return -1;
    }

    MainWindow browser(url,year,month,day,outputPath);
    browser.show();
    return app.exec();
}
开发者ID:jasonz88,项目名称:NewsGrabber,代码行数:35,代码来源:main.cpp


注:本文中的QCommandLineParser::addPositionalArgument方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。