struct option longopts[] =
{
- { "version", no_argument, NULL, 'v' },
+ { "greeting", required_argument, NULL, 'g' },
{ "help", no_argument, NULL, 'h' },
- { "traditional", no_argument, NULL, 't' },
- { "next-generation", no_argument, NULL, 'n' },
{ "mail", no_argument, NULL, 'm' },
+ { "next-generation", no_argument, NULL, 'n' },
+ { "traditional", no_argument, NULL, 't' },
+ { "version", no_argument, NULL, 'v' },
{ NULL, 0, NULL, 0 }
};
{
int optc;
int h = 0, v = 0, t = 0, m = 0, n = 0, lose = 0, z = 0;
+ char *greeting = NULL;
progname = argv[0];
textdomain (PACKAGE);
#endif
- while ((optc = getopt_long (argc, argv, "hmntv", longopts, (int *) 0))
+ while ((optc = getopt_long (argc, argv, "g:hmntv", longopts, (int *) 0))
!= EOF)
switch (optc)
{
case 'v':
v = 1;
break;
+ case 'g':
+ greeting = optarg;
+ break;
case 'h':
h = 1;
break;
fputs (_("\
-t, --traditional use traditional greeting format\n\
-n, --next-generation use next-generation greeting format\n\
+ -g, --greeting=TEXT use TEXT as the greeting message\n\
-m, --mail print your mail\n"), stdout);
printf ("\n");
+---------------+\n\
"));
else
- puts (_("Hello, world!"));
+ {
+ if (!greeting)
+ greeting = _("Hello, world!");
+ puts (greeting);
+ }
}
exit (0);