Add minimal command line parser to YACReader and YACReaderLibrary.

Introduce new command line options --comicId and --libraryId for
communication between Reader and Library.
Support for standard command line options --help and --version.
This commit is contained in:
Felix Kauselmann
2014-08-08 20:42:14 +02:00
parent b2e3e77495
commit 1f4f524397
7 changed files with 126 additions and 11 deletions

View File

@ -10,6 +10,7 @@
#include <QSettings>
#include <QLibrary>
#include <QMessageBox>
#include <QTextStream>
#include "yacreader_global.h"
#include "startup.h"
@ -141,6 +142,31 @@ int main( int argc, char ** argv )
app.setApplicationName("YACReaderLibrary");
app.setOrganizationName("YACReader");
//simple command line parser
//will be replaced by QCommandLineParser in the future
//TODO: --headless, --server=[on|off], support for file and directory arguments
if (argc > 1)
{
QTextStream parser(stdout);
QStringList optlist = QCoreApplication::arguments().filter(QRegExp ("^-{1,2}"));
if (optlist.contains("--version") | optlist.contains("-v"))
{
parser << app.applicationName() << " " << QString(VERSION) << endl << "Copyright 2014 by Luis Angel San Martin Rodriguez" << endl;
return 0;
}
if (optlist.contains("--help") | optlist.contains("-h"))
{
parser << endl << "Usage:" << "\tYACReaderLibrary [Option]" << endl << endl;
parser << "Options:" << endl;
parser << " none\t\t\tStart YACReaderLibrary" << endl;
parser << " -h, --help\t\tDisplay help text and exit." << endl;
parser << " -v, --version\t\tDisplay version information and exit." << endl;
return 0;
}
parser << "Unsupported command line options. See YACReaderLibrary --help for further information." << endl;
return 0;
}
QString destLog = YACReader::getSettingsPath()+"/yacreaderlibrary.log";
QDir().mkpath(YACReader::getSettingsPath());