|
From: <li...@mi...> - 2007-07-09 15:55:01
|
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
>
|