Skip to content

Commit

Permalink
Try simplifying the test case
Browse files Browse the repository at this point in the history
  • Loading branch information
pcolby committed Nov 17, 2023
1 parent 4fccbb4 commit 7400a05
Showing 1 changed file with 31 additions and 29 deletions.
60 changes: 31 additions & 29 deletions src/cli/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include <Windows.h>
#endif

static Q_LOGGING_CATEGORY(lc, "dokit.cli.main", QtInfoMsg);
//static Q_LOGGING_CATEGORY(lc, "dokit.cli.main", QtInfoMsg);

inline bool haveConsole()
{
Expand Down Expand Up @@ -311,33 +311,35 @@ int main(int argc, char *argv[])
QCoreApplication::installTranslator(&libTranslator);
}

// Parse the command line.
const QStringList appArguments = QCoreApplication::arguments();
QCommandLineParser parser;
const Command commandType = parseCommandLine(appArguments, parser);
qCDebug(lc).noquote() << QCoreApplication::applicationName() << QCoreApplication::applicationVersion();
qCDebug(lc).noquote() << "Qt" << qVersion() << "(runtime) [" QT_VERSION_STR " compile-time]";
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)) // QTranslator::filePath() added in Qt 5.15.
qCDebug(lc).noquote() << "App translations:" <<
(appTranslator.filePath().isEmpty() ? QStringLiteral("<none>") : appTranslator.filePath());
qCDebug(lc).noquote() << "Library translations:" <<
(libTranslator.filePath().isEmpty() ? QStringLiteral("<none>") : libTranslator.filePath());
#else
qCDebug(lc).noquote() << "App translations:" << (!appTranslator.isEmpty());
qCDebug(lc).noquote() << "Lib translations:" << (!libTranslator.isEmpty());
#endif
return 0;

// Handle the given command.
AbstractCommand * const command = getCommandObject(commandType, &app);
if (command == nullptr) {
return EXIT_FAILURE; // getCommandObject will have logged the reason already.
}
const QStringList cliErrors = command->processOptions(parser);
for (const QString &error: cliErrors) {
showCliError(error);
}
if (!cliErrors.isEmpty()) {
return EXIT_FAILURE;
}
return (command->start()) ? QCoreApplication::exec() : EXIT_FAILURE;
// // Parse the command line.
// const QStringList appArguments = QCoreApplication::arguments();
// QCommandLineParser parser;
// const Command commandType = parseCommandLine(appArguments, parser);
// qCDebug(lc).noquote() << QCoreApplication::applicationName() << QCoreApplication::applicationVersion();
// qCDebug(lc).noquote() << "Qt" << qVersion() << "(runtime) [" QT_VERSION_STR " compile-time]";
//#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)) // QTranslator::filePath() added in Qt 5.15.
// qCDebug(lc).noquote() << "App translations:" <<
// (appTranslator.filePath().isEmpty() ? QStringLiteral("<none>") : appTranslator.filePath());
// qCDebug(lc).noquote() << "Library translations:" <<
// (libTranslator.filePath().isEmpty() ? QStringLiteral("<none>") : libTranslator.filePath());
//#else
// qCDebug(lc).noquote() << "App translations:" << (!appTranslator.isEmpty());
// qCDebug(lc).noquote() << "Lib translations:" << (!libTranslator.isEmpty());
//#endif

// // Handle the given command.
// AbstractCommand * const command = getCommandObject(commandType, &app);
// if (command == nullptr) {
// return EXIT_FAILURE; // getCommandObject will have logged the reason already.
// }
// const QStringList cliErrors = command->processOptions(parser);
// for (const QString &error: cliErrors) {
// showCliError(error);
// }
// if (!cliErrors.isEmpty()) {
// return EXIT_FAILURE;
// }
// return (command->start()) ? QCoreApplication::exec() : EXIT_FAILURE;
}

0 comments on commit 7400a05

Please sign in to comment.