Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[buteo-mtp] Use QCommandLineParser for parsing arguments
Rolling custom command line parsers causes problems in the long run.

Switch from custom parser to using QCommandLineParser.

Signed-off-by: Simo Piiroinen <simo.piiroinen@jollamobile.com>
  • Loading branch information
spiiroin committed Feb 27, 2019
1 parent 9a45b69 commit f04de40
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion service/service.cpp
Expand Up @@ -25,6 +25,7 @@
#include <signal.h>
#include <iostream>
#include <QCoreApplication>
#include <QCommandLineParser>
#include <QDir>
#include <QObject>
#include <QEventLoop>
Expand All @@ -49,6 +50,14 @@ void signalHandler(int signum, siginfo_t *info, void *context)
int main(int argc, char** argv)
{
QCoreApplication app(argc, argv);
QCommandLineParser parser;
parser.setApplicationDescription("standalone buteo-mtp daemon");
parser.addHelpOption();
QCommandLineOption logToHomeOption(QStringList() << "d" << "log-to-home",
"Log to \"$HOME/mtp.log\".");
parser.addOption(logToHomeOption);
parser.process(app);
bool logToHome(parser.isSet(logToHomeOption));

struct sigaction action;

Expand All @@ -68,7 +77,7 @@ int main(int argc, char** argv)
bool ok = Mts::getInstance()->activate();
if( ok )
{
if (app.arguments().count() > 1 && app.arguments().at(1) == "-d")
if (logToHome)
{
Buteo::Logger::createInstance(QDir::homePath() + "/mtp.log", false, 0);
if (!Mts::getInstance()->debugLogsEnabled())
Expand Down

0 comments on commit f04de40

Please sign in to comment.