✨feat: 添加命令行运行版本用于批量运行
update gencode
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
#include <QCommandLineParser>
|
||||
#include <QCoreApplication>
|
||||
#include <QTimer>
|
||||
#include "task.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QCoreApplication a(argc, argv);
|
||||
|
||||
QCoreApplication::setApplicationName("batsil");
|
||||
QCoreApplication::setApplicationVersion("1.0");
|
||||
|
||||
QCommandLineParser parser;
|
||||
parser.setApplicationDescription("Batch SIL App");
|
||||
parser.addHelpOption();
|
||||
parser.addVersionOption();
|
||||
parser.addPositionalArgument("param", "parameter file.");
|
||||
// An option with a value
|
||||
QCommandLineOption idxOption(QStringList() << "i" << "idx",
|
||||
"index in file.", "idx","1");
|
||||
parser.addOption(idxOption);
|
||||
|
||||
// Process the actual command line arguments given by the user
|
||||
parser.process(a);
|
||||
|
||||
const QStringList args = parser.positionalArguments();
|
||||
QString fn;
|
||||
if (args.count() > 0)
|
||||
{
|
||||
fn = args.at(0);
|
||||
}
|
||||
|
||||
int idx = parser.value(idxOption).toInt();
|
||||
|
||||
// Task parented to the application so that it
|
||||
// will be deleted by the application.
|
||||
Task *task = new Task(&a, fn, idx);
|
||||
|
||||
// This will cause the application to exit when
|
||||
// the task signals finished.
|
||||
QObject::connect(task, SIGNAL(finished()), &a, SLOT(quit()));
|
||||
|
||||
// This will run the task from the application event loop.
|
||||
QTimer::singleShot(0, task, SLOT(run()));
|
||||
|
||||
return a.exec();
|
||||
}
|
||||
Reference in New Issue
Block a user