igor.mironchik at gmail.com
Thu May 4 08:22:01 CEST 2017
I know that Qt already has its own stuff for CLI parsing. I don't
remember who told it, but - more good libraries, more and more...
I want to tell you about Args. Probably you know about QtArg. So QtArg
is a parent of Args. Args on one side a little simpler than QtArg, but
on another side it has different features. Args support both worlds -
pure C++ (with std::string or std::wstring) and Qt with QString. You
just define ARGS_WSTRING_BUILD, ARGS_QSTRING_BUILD or nothing to build
Args with std::wstring, QString or std::string support.
Bellow is release announcement of Args 3.0.1
"First of all I have to say about new features in Args version
3.0.1. In this version was added new class ArgAsCommand. This is
special argument with name like in Command (i.e. without starting
dashes). But this is not a command. Command can has child arguments,
groups. But ArgAsCommand can't. It can has one value or many values,
or can be without value. ArgAsCommand can be defined only once in
CLI. And ArgAsCommand can be added into groups and commands.
I wrote about commands, but what is it?! Command is an argument in
CLI without starting dashes, like "add", "delete", "move". And in
command developer can add child arguments. Child argument are valid
only if command was defined. This is reflected in help of Args, I
wrote about it.
And groups... Why developer need them? Groups are useful for
checking of state of arguments after parsing. You can just say - I
want arguments "-a" and "-b" to be required and I want only one of
arguments "-c" and "-d" be required, i.e. if defined both "-c" and
"-d" - is an error. You can mix groups in any way, you can nest
them. And I suggest to name groups like - "only one argument can be
defined - "-c" or "-d"". In this case user will see understandable
error message if he will put wrong arguments.
Since first version of Args there are two types of arguments. These
are Arg and MultiArg. Different is simple - Arg can be defined only
once whereas MultiArg can be defined multiply times. These arguments
can be with value or without, can be required or not.
And one more thing that you should know about groups - you can't add
required argument into group, and you can't add command into it. But
if group is AllOfGroup and it's required then in help arguments of
this group will be printed as required."
And in Args 4.0.0 was added support of different string types.
Major difference of Args with QtArg that Args doesn't support any number
of names of argument, you just can specify name and flag. But in Args
implemented different groups and ArgAsCommand. And in Args you can't
shorten name of argument, you have to write full name.
I think that I will stop further development of QtArg, I will fix bugs
only, but new features I will not add.
Args you can find here - https://github.com/igormironchik/args-parser
This email has been checked for viruses by AVG.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Interest