[Development] QCommandLineParser

David Faure david.faure at kdab.com
Tue Jul 30 14:35:39 CEST 2013

On Tuesday 30 July 2013 10:30:41 Oswald Buddenhagen wrote:
> On Mon, Jul 29, 2013 at 08:38:38PM +0200, David Faure wrote:
> > So after more thinking, here's my suggestion:
> > * we keep the idea that every main() creates a parser on the stack. The
> > current change request can go in (after more reviewing).
> > * later if we want to use QCommandLineParser for the builtin qapp options,
> > qcoreapp would create its own *separate* instance,
> note that i already commented on that, too.
> the problem with any kind of separate parser is that if two independent
> parsers try to process the same command line, you are bound for
> anomalies, specifically one parser interpreting as options what the
> other parser would see as arguments to other options.

This is already the case though. The builtin parsing in qapp can't know that 
some arguments are in fact option values from the app's point of view.
So yeah, app -title -reverse is broken already if the app defines (later) that 
-title takes a value, and would remain broken (qapp will activate reverse 
mode). We can't do much about that, can we (given the constraints of qcoreapp 
running before the options from main are added)? It's really corner case IMHO.
Option values starting with a '-' are really uncommon.

> the cleanest solution would be entirely discarding the qapp-internal
> parsing and having the user-supplied parser explicitly fed into qapp
> (fwiw, that's what app developers want anyway. i have already fed fake
> command lines to qapp just to make it happy).
> however, due to the instantiation order constraints that would mean
> delaying the cmdline-dependent setup in qapp, which is said to be tricky
> ...

Exactly. So I don't consider this an option.
Cleanest doesn't always agree with history.

David Faure | david.faure at kdab.com | Managing Director KDAB France
KDAB (France) S.A.S., a KDAB Group company
Tel. France +33 (0)4 90 84 08 53, Sweden (HQ) +46-563-540090
KDAB - Qt Experts - Platform-independent software solutions

More information about the Development mailing list