aboutsummaryrefslogtreecommitdiffstats
path: root/src/command_line.cpp
diff options
context:
space:
mode:
authorConfuSomu2023-06-10 18:53:35 -0400
committerConfuSomu2023-06-10 18:59:30 -0400
commit7e4c7905c9e74d76de2e03413af0dc9e4cb84683 (patch)
treeca0de8ab135ecc9af006664b5f505c0e2415de5a /src/command_line.cpp
parentd3d14e07c202f9350f817802777720ded85e4248 (diff)
downloadActorViewer-7e4c7905c9e74d76de2e03413af0dc9e4cb84683.tar
ActorViewer-7e4c7905c9e74d76de2e03413af0dc9e4cb84683.tar.gz
ActorViewer-7e4c7905c9e74d76de2e03413af0dc9e4cb84683.zip
Implement command line options
Implementing a command line argument specifying the data export to open allows iterating faster as the file to open can be specified without navigating through a GUI. In the future, more command line options could be specified to specify the view filters for instance.
Diffstat (limited to 'src/command_line.cpp')
-rw-r--r--src/command_line.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/command_line.cpp b/src/command_line.cpp
new file mode 100644
index 0000000..d16742a
--- /dev/null
+++ b/src/command_line.cpp
@@ -0,0 +1,28 @@
+#include "src/command_line.h"
+
+#include <QDebug>
+#include <QApplication>
+
+CommandLineParsedOptions parse_command_line(QCommandLineParser &parser, QApplication &app) {
+ QCommandLineOption fileOption({"f", "file"},
+ QCoreApplication::translate("cmdline", "Data export to open."),
+ "file");
+ parser.addOption(fileOption);
+
+ const QCommandLineOption help_option = parser.addHelpOption();
+ const QCommandLineOption version_option = parser.addVersionOption();
+
+ QString outbox_filename;
+
+ if (!parser.parse(app.arguments()))
+ return {CommandLineError, parser.errorText(), outbox_filename};
+
+ if (parser.isSet(help_option) or parser.isSet("help-all"))
+ return {CommandLineHelpRequested, nullptr, outbox_filename};
+ if (parser.isSet(version_option))
+ return {CommandLineVersionRequested, nullptr, outbox_filename};
+
+ outbox_filename = parser.value(fileOption);
+
+ return {CommandLineOk, nullptr, outbox_filename};
+}