Martin Landa wrote:
[snip]
> > 2) It seems better to add the type 'all' to g.list manually
> > (especially because of the requested type parameter). I am not sure
> > how to do it in an elegant way (see the patch) - my approach seems to
> > be very ugly.
>
> I would abandon the approach of having a separate "parse" function in
> favour of iterating over element->answers and listing each type as
> it's encountered.well, I have tried to simplify the patch. Functions parse() &
do_list() are now called for each element->answers[i]. I hope it is
better now.
+ if (G_parser(argc, argv))
+ {
+ fprintf (stderr, _("\nWhere %s is one of:\n"), element->key);
+ show_elements();
+ exit(EXIT_FAILURE);
+ }
If G_parser() fails, the program should just call exit(EXIT_FAILURE);
G_parser() will print an error message detailing why it failed.
> lib/do_list.c doesn't need to change; just have cmd/list.c call
> do_list() once for each type.I think that fn do_list() have to be rewritten because of the -f flags
(calling of execl() fn) ?
No; do_list() can remain untouched, while the handling of -f should
remain essentially the same, except that it should use G_spawn()
instead of execl().
--
Glynn Clements <glynn@gclements.plus.com>