QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
QGCCommandLineParser.h
Go to the documentation of this file.
1#pragma once
2
3#include <optional>
4#include <utility>
5
6#include <QtCore/QCommandLineParser>
7#include <QtCore/QStringList>
8
9namespace QGCCommandLineParser {
10
17{
24
25 std::unique_ptr<QCommandLineParser> parser;
26
27 std::optional<QString> errorString;
28 QString helpText;
29 QString versionText;
30
31 QStringList positional;
32 QStringList unknownOptions;
33
34 // --- Core options ---
35 std::optional<quint32> systemId;
37 bool clearCache = false;
38 std::optional<QString> loggingOptions;
39 bool logOutput = false;
40 bool simpleBootTest = false;
41
42 // --- Test options (command-line parsing only in QGC_UNITTEST_BUILD) ---
43 bool runningUnitTests = false;
44 QStringList unitTests;
45 bool stressUnitTests = false;
47 std::optional<QString> unitTestOutput;
50 std::optional<QString> labelFilter;
51 bool listTests = false;
52 bool onscreen = false;
53
54 // --- Desktop options (not on Android/iOS) ---
55 bool fakeMobile = false;
56 bool allowMultiple = false;
57
58 // --- Graphics options ---
59 bool useSwRast = false;
60 bool quietWindowsAsserts = false;
61};
62
67
73CommandLineParseResult parse(int argc, char* argv[]);
74
78std::optional<int> handleParseResult(const CommandLineParseResult& result);
79
81enum class AppMode {
84#ifdef QGC_UNITTEST_BUILD
85 Test,
86 ListTests
87#endif
88};
89
93AppMode determineAppMode(const CommandLineParseResult& args);
94
97std::optional<quint32> parseSystemId(const QString& value);
98
101std::optional<std::pair<uint, uint>> parseUnitTestShard(const QString& value);
102
103#ifdef QGC_UNITTEST_BUILD
104QStringList normalizeArgs(const QStringList &args);
105
111void overrideCommandLine(int& argc, char**& argv);
112#endif
113
114} // namespace QGCCommandLineParser
CommandLineParseResult parse(int argc, char *argv[])
Parse command-line arguments with automatic QCoreApplication management.
AppMode determineAppMode(const CommandLineParseResult &args)
Determine the application mode from parsed arguments.
std::optional< std::pair< uint, uint > > parseUnitTestShard(const QString &value)
Validate a –unittest-shard value of the form <index>/<count>.
std::optional< quint32 > parseSystemId(const QString &value)
Validate a –system-id value.
AppMode
Application execution mode.
@ BootTest
Initialize and exit (for CI validation).
CommandLineParseResult parseCommandLine()
Parse command-line arguments (requires existing QCoreApplication).
static QStringList normalizeArgs(const QStringList &args)
Normalizes command-line arguments Converts colon-separated syntax (–option:value) to standard format ...
std::optional< int > handleParseResult(const CommandLineParseResult &result)
Handle early exit conditions (help, version, error).
Result of parsing command-line arguments.
bool quietWindowsAsserts
Windows only: Disable assert dialogs.
std::unique_ptr< QCommandLineParser > parser
bool listTests
List available tests and exit.
uint unitTestShardCount
Number of shards the test's functions are split into.
enum QGCCommandLineParser::CommandLineParseResult::Status statusCode
std::optional< QString > labelFilter
Filter tests by label (comma-separated).
bool useSwRast
Windows/macOS: Force software rendering.
std::optional< QString > unitTestOutput
Output file for test results (JUnit XML).
uint unitTestShardIndex
1-based shard of the test's functions to run (0 = all functions)
bool onscreen
Show test windows on screen (skip offscreen override).