[Development] QCommandLineParser

Александр Волков volkov0aa at gmail.com
Thu Aug 1 20:49:00 CEST 2013


On Mon, Jul 29, 2013 at 08:38:38PM +0200, David Faure wrote:
> I also ported all of KDE Frameworks 5's executables.

Just compare how it was (kconf_update):
> KCmdLineOptions options;
> options.add("debug", ki18n("Keep output results from scripts"));
> options.add("check <update-file>", ki18n("Check whether config file 
> itself requires updating"));
> options.add("+[file]", ki18n("File to read update instructions from"));
> ...
>
> KCmdLineArgs::init(argc, argv, &aboutData);
> KCmdLineArgs::addCmdLineOptions(options);

And how it looks now:
> QCommandLineParser *parser = new QCommandLineParser;
> parser->addVersionOption("1.1");
> parser->addHelpOption(QCoreApplication::translate("main", "KDE Tool 
> for updating user configuration files"));
> parser->addOption(QCommandLineOption(QStringList() << "debug", 
> QCoreApplication::translate("main", "Keep output results from scripts")));
> parser->addOption(QCommandLineOption(QStringList() << "check", 
> QCoreApplication::translate("main", "Check whether config file itself 
> requires updating"), QCommandLineOption::WithValue));
> parser->addOption(QCommandLineOption(QStringList() << "+[file]", 
> QCoreApplication::translate("main", "File to read update instructions 
> from")));

It's really bad to make programmers write an excessive code like 
"QCommandLineOption(QStringList() <<".
It's even worse in uic and moc:
> QCommandLineOption dependenciesOption(QStringList() << 
> QStringLiteral("d") << QStringLiteral("dependencies"));
> dependenciesOption.setDescription(QStringLiteral("Display the 
> dependencies."));
> parser.addOption(dependenciesOption);

Why??? It must be like that: options.add("d").add("dependencies", 
QStringLiteral("Display the dependencies."));
I feel like I'm in a nightmare. What's the point to invent a bicycle 
that's worse than the existing one?




More information about the Development mailing list