From: <li...@mi...> - 2007-08-01 17:35:45
|
On Sun, Jul 29, 2007 at 09:32:09AM -0500, Mike Borella wrote: > Michael Geng wrote: > >Hi Mike, > > > >I think one of the most obvious missing features of Genparse is that > >it doesn't yet support optional arguments. getopt_long supports > >optional arguments however. > > > >I want to implement it by allowing an optional * both after the > >short and the long option. > > > >Examples: > > > >o* / oparam* string "Both short and long option have an optional > >argument." > >p* / pparam string "Short option has an optional argument," > > "long option requires an argument." > >q / qparam* string "Short option reqires an argument," > > "long option has an optional argument." > > > >Michael > > > > Does this mean that these arguments could be both flag as well as > parameterized? That's a good point. For indicating if the option was specified at all I don't see another solution than adding a flag to every optional argument in the arg_t struct. So the above example will lead to the following arg_t struct: struct arg_t { char * o; bool o_flag; char * p; bool p_flag; char * q; bool q_flag; }; Everything will stay compatible however because only optional arguments require both value and flag so the implementations for mandatory arguments or arguments with an explicit flag type will not be changed. Michael |