[Development] [Qt5-feedback] Command line parser in QtCore?

Craig.Scott at csiro.au Craig.Scott at csiro.au
Sun Oct 23 01:13:41 CEST 2011


On 23/10/2011, at 1:43 AM, Pau Garcia i Quiles wrote:

Hi,

Have you tried QCommandLine?

http://xf.iksaif.net/dev/qcommandline.html
http://gitorious.org/qcommandline


No, I hadn't seen that. Looking at the example usage though, I can see one immediate drawback. It uses signals and slots to tell you what flags, switches, etc. it finds during parsing. This means at the time you find out about a flag, you only know about the things that have been parsed up to that point on the command line. It doesn't give you a global view of all the flags/arguments that were provided (or not provided!) on the command line. That makes validation harder, so you would have to do your validation after your call to parse(). It also tends to fragment your flag/argument handling by requiring each one to have its own slot. Seems overly verbose to me.

I also find that there isn't really a need to differentiate between switches, flags and options so explicitly. Much of this is implied by whether or not your flag has parameters associated with it. Maybe there's some useful cases where this isn't true, but we've found the simplicity of the approach we've taken makes it really easy to work with and understand.

--
Dr Craig Scott
Computational Software Engineering Team Leader, CSIRO (CMIS)
Melbourne, Australia






More information about the Development mailing list