[Development] QCommandLineParser

David Faure faure at kde.org
Thu Aug 1 11:07:36 CEST 2013


On Tuesday 30 July 2013 12:54:28 Andreas Aardal Hanssen wrote:
> I can't help getting the feeling that the community is about to make the
> same mistake again regarding command line parsing in Qt.

No, because unlike previous attempts, I do intend to go the last mile and 
actually get this into Qt :-)

> My $0.02 is to make something that's ridiculously simple, or cancel the
> whole project. We already have other options for complex cases. Qt apps
> traditionally don't take complex arguments and they really shouldn't.
> Simple -foo blah is enough, and it works the same way on all platforms.
> Please don't overengineer this parser. Don't make platform specifics like
> '/' on Windows and '--foo=blah' on Unix. 

I'll remove '/' on Windows, since that seems to be the consenssus.
I will however keep --foo blah (and --foo=blah), but they work everywhere (so 
it's not platform-specific). Single-dash "-abc" can be either -a -b -c or -abc 
or -a bc, all of which are needed, see https://codereview.qt-project.org/61746
I don't think that's making things complex, it's just making it useful for 
different types of apps (including preserving compat with the current Qt 
tools).

Things have to be simple, but not the point where they are not useful.

> Remember that most folks just make
> a for loop to check arguments, i.e., if (arguments.at(i) == "-fullscreen")
> { fullScreen = true; }.

Yeah, and then they don't implement --help, or they don't maintain it, and it 
becomes outdated compared to the actual supported options. I have proof, I 
found bugs in --help in both moc and uic, when porting them.

> The Qt API must be simpler than this, and it's
> really hard to get there if this class is to support all kinds of crap.

The API is simple, and I see no "crap".

-- 
David Faure, faure at kde.org, http://www.davidfaure.fr
Working on KDE, in particular KDE Frameworks 5




More information about the Development mailing list