quake-tools/source/quam/main.cc
2019-10-04 13:37:34 -04:00

62 lines
1.3 KiB
C++

#include "quam/archive.h"
#include "quam/main_window.h"
#include <QApplication>
#include <QCommandLineParser>
#include <QCoreApplication>
static void setupAppl(QCoreApplication &appl) {
appl.setApplicationName("QuAM!");
appl.setApplicationVersion("1.0");
appl.setOrganizationDomain("greyserv.net");
appl.setOrganizationName("Project Golan");
}
static int modeGui(int argc, char *argv[]) {
QApplication appl{argc, argv};
setupAppl(appl);
MainWindow win;
win.show();
return appl.exec();
}
static int modeText(int argc, char *argv[]) {
QCoreApplication appl{argc, argv};
setupAppl(appl);
QCommandLineParser par;
par.setApplicationDescription("Quake Archive Manager");
par.setSingleDashWordOptionMode(
QCommandLineParser::ParseAsCompactedShortOptions);
par.addHelpOption();
par.addVersionOption();
QCommandLineOption fileNameOpt{QStringList{"f", "file"},
trMain("Open the archive <file>."),
trMain("file")};
par.addOption(fileNameOpt);
par.process(appl);
auto fileName = par.value(fileNameOpt).toStdString();
auto st = openReadBin(fileName);
auto arc = Arc::readArchive(st);
qDebug() << arc;
return 0;
}
int main(int argc, char *argv[]) {
if(argc <= 1) {
return modeGui(argc, argv);
} else {
return modeText(argc, argv);
}
}
// EOF