I am working on a simple command line parser using QCommandLineParser class(Qt Version 5.4.0). Below is the code:
#include <QCommandLineOption>
#include <QCommandLineParser>
#include <QCoreApplication>
#include <QDebug>
#include <QString>
#include <QStringList>
int main(int argc, char *argv[])
{
QCommandLineParser parser;
parser.addHelpOption();
parser.process(app);
return 0;
}
#include <QCommandLineOption>
#include <QCommandLineParser>
#include <QCoreApplication>
#include <QDebug>
#include <QString>
#include <QStringList>
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
QCommandLineParser parser;
parser.addHelpOption();
parser.process(app);
return 0;
}
To copy to clipboard, switch view to plain text mode
When I execute the program, I see the following output
>./firstCommandLineParser --help
Usage: ./firstCommandLineParser [options]
Options:
-h, --help Displays this help.
The format of usage information displayed contains only [options] and additionally I can specify positional arguments with addPositionalArgument method.
However, I want to see the usage information displayed in the following format:
Usage: ./firstCommandLineParser [-d/-D] directory -s configFile
Can you please suggest a method to do this?
Bookmarks