From: Mike B. <mi...@bo...> - 2007-07-08 19:47:58
|
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? Thanks, Mike 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 |