Re: how to deal with shared parameters for multiple programs?
Erik Sjölund <[email protected]> Fri, 2 Mar 2012 19:02:08 +0100
| Newsgroups | gmane.comp.gnu.gengetopt.general |
|---|---|
| Message-ID | <CAB+1q0T9Csb953v4gQV45ZHcscAsaeAUVbtvzSFb0VzVbyKuOQ@mail.gmail.com> |
On Sun, Jan 2, 2011 at 5:21 PM, Erik Sj=F6lund <[email protected]> wro= te: > Hi Lorenzo, > >> I think a possible solution is to allow a .ggo file to include another o= ne, >> which is something is still to be implemented in gengetopt... > > Yes, I read about the plans. Before that is being implemented it is > always possible to use > cmake or some other tool to generate out the .ggo files. I got an idea. If in addition to cmdline_parser (argc, argv, &args_info) there would also be a cmdline_parser_allow_unknown_flags(argc, argv, &args_info) and if there also would be an include directive in gengetopt configuration files, a program could first let gengetopt parse all the flags of the program (implemented with includes and cmdline_parser(argc, argv, &args_info)). After that the program would run the function cmdline_parser_allow_unknown_flags(argc, argv, &args_info2) that was generated out of only the common flags. Advantage: If you have multiple programs that have common flags, you avoid duplicating code. Drawbacks: This solution would mean that argv would be parsed twice. Also group options would be troublesome. cheers, Erik Sj=F6lund