|
From: <li...@mi...> - 2007-07-11 05:46:01
|
On Mon, Jul 09, 2007 at 05:01:05PM -0500, Mike Borella wrote:
> Does this mean that you can't define your own -i option?
>
> Mike
I'm afraid you are confusing the Genparse file of Genparse itself
and the Genparse file of the program for which you want to write a
command line parser.
I'm proposing to add the following line to the Genparse file for
Genparse:
i / internationalize flag "Put internationalization macro _() around text output."
If you invoke Genparse with the -i or --internationalize option
then it will add the internationalization macro _() around output
text like the help text in the usage() function.
But of course you can still have a -i option in the Genparse file
for the program for which you want to generate a command line parser.
Do you understand or did I completely confuse you now? Do you know
about internationalization using the GNU gettext command?
Michael
> Michael Geng wrote:
> >On Sun, Jul 08, 2007 at 02:48:02PM -0500, Mike Borella wrote:
> >>Michael,
> >>
> >>I like passing the status to the usage() function. However I was a
> >>little confused with the -i option especially since the example already
> >>uses the -i option. Would that have to change?
> >
> >The Genparse file below is from the mycopy3 example. Genparse itself
> >doesn't yet have a -i option, so there's no conflict.
> >
> >Michael
> >
> >>Michael Geng wrote:
> >>>Hi Mike,
> >>>
> >>>this is the usage() function of the mycopy3 example as it is now:
> >>>
> >>>void usage(char *executable)
> >>>{
> >>> printf("\
> >>>usage: %s [ -iohv ] file\n\
> >>> [ -i ] [ --iterations ] (type=INTEGER, range=0..., default=1)\n\
> >>> Number of times to output <file>.\n\
> >>> File should be text format!\n\
> >>> [ -o ] [ --outfile ] (type=STRING)\n\
> >>> Output file.\n\
> >>> [ -h ] [ --help ] (type=FLAG)\n\
> >>> Display help information.\n\
> >>> [ -v ] [ --version ] (type=FLAG)\n\
> >>> Output version.\n", executable);
> >>>
> >>> exit(1);
> >>>}
> >>>
> >>>I propose to change it like this:
> >>>
> >>>void usage(int status, char *executable)
> >>>{
> >>> if (status != EXIT_SUCCESS)
> >>> fprintf(stderr, "Try `%s --help' for more information.\n",
> >>> executable);
> >>> else
> >>> {
> >>> printf("\
> >>>usage: %s [ -iohv ] file\n\
> >>> [ -i ] [ --iterations ] (type=INTEGER, range=0..., default=1)\n\
> >>> Number of times to output <file>.\n\
> >>> File should be text format!\n\
> >>> [ -o ] [ --outfile ] (type=STRING)\n\
> >>> Output file.\n\
> >>> [ -h ] [ --help ] (type=FLAG)\n\
> >>> Display help information.\n\
> >>> [ -v ] [ --version ] (type=FLAG)\n\
> >>> Output version.\n", executable);
> >>> }
> >>> exit(status);
> >>>}
> >>>
> >>>Another proposal is to add a new command line switch
> >>>-i / --internationalization and put the internationalization
> >>>macro _() around strings in the usage() function. Invoking
> >>>Genparse with -i set would result in the following usage()
> >>>function:
> >>>
> >>>void usage(int status, char *executable)
> >>>{
> >>> if (status != EXIT_SUCCESS)
> >>> fprintf(stderr, _("Try `%s --help' for more information.\n"),
> >>> executable);
> >>> else
> >>> {
> >>> printf(_("\
> >>>usage: %s [ -iohv ] file\n\
> >>> [ -i ] [ --iterations ] (type=INTEGER, range=0..., default=1)\n\
> >>> Number of times to output <file>.\n\
> >>> File should be text format!\n\
> >>> [ -o ] [ --outfile ] (type=STRING)\n\
> >>> Output file.\n\
> >>> [ -h ] [ --help ] (type=FLAG)\n\
> >>> Display help information.\n\
> >>> [ -v ] [ --version ] (type=FLAG)\n\
> >>> Output version.\n"), executable);
> >>> }
> >>> exit(status);
> >>>}
> >>>
> >>>Michael
> >>>
> >>
> >>--
> >>Mike Borella
> >>mike at borella dot net
> >>http://www.borella.net/mike
> >>
> >
>
>
> --
> Mike Borella
> mike at borella dot net
> http://www.borella.net/mike
>
|