MCPcopy Create free account
hub / github.com/Simsys/qhexedit2 / parseCommandLine

Function parseCommandLine

example/main.cpp:29–54  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27};
28
29CommandLineParseResult parseCommandLine(QCommandLineParser &parser, ParsedOptions *query) {
30 using Status = CommandLineParseResult::Status;
31
32 const QCommandLineOption helpOption = parser.addHelpOption();
33 const QCommandLineOption versionOption = parser.addVersionOption();
34 parser.addPositionalArgument("file", "File to open");
35
36 if (!parser.parse(QCoreApplication::arguments()))
37 return { Status::Error, parser.errorText() };
38
39 if (parser.isSet(versionOption))
40 return { Status::VersionRequested };
41
42 if (parser.isSet(helpOption))
43 return { Status::HelpRequested };
44
45 const QStringList positionalArguments = parser.positionalArguments();
46 if (!positionalArguments.isEmpty()) {
47 if (positionalArguments.size() > 1)
48 return { Status::Error, "Several 'name' arguments specified." };
49 query->hasFile = true;
50 query->file = positionalArguments.first();
51 }
52
53 return { Status::Ok };
54}
55
56int main(int argc, char *argv[])
57{

Callers 1

mainFunction · 0.85

Calls 1

sizeMethod · 0.80

Tested by

no test coverage detected