fish: improve the command error messages

- when a command needs no parameters, tell that explicitly instead of
  "command should have 0 parameters"
- use gettext's plural form when printing the number of required
  arguments
- improve the error message for a variable number of parameters limited
  only in the maximum number of them, using also a plural form
This commit is contained in:
Pino Toscano
2013-12-05 16:30:06 +01:00
committed by Richard W.M. Jones
parent 1a9a8ab48f
commit c60dc40fe4

View File

@@ -362,12 +362,24 @@ Guestfish will prompt for these separately."
if argc_minimum = argc_maximum then (
pr " if (argc != %d) {\n" argc_minimum;
pr " fprintf (stderr, _(\"%%s should have %%d parameter(s)\\n\"), cmd, %d);\n"
argc_minimum;
if argc_minimum = 0 then (
pr " fprintf (stderr, _(\"%%s should have no parameters\\n\"), cmd);\n";
) else (
pr " fprintf (stderr, ngettext(\"%%s should have %%d parameter\\n\",\n";
pr " \"%%s should have %%d parameters\\n\",\n";
pr " %d),\n"
argc_minimum;
pr " cmd, %d);\n"
argc_minimum;
)
) else if argc_minimum = 0 then (
pr " if (argc > %d) {\n" argc_maximum;
pr " fprintf (stderr, _(\"%%s should have %%d-%%d parameter(s)\\n\"), cmd, %d, %d);\n"
argc_minimum argc_maximum;
pr " fprintf (stderr, ngettext(\"%%s should have at most %%d parameter\\n\",\n";
pr " \"%%s should have at most %%d parameters\\n\",\n";
pr " %d),\n"
argc_maximum;
pr " cmd, %d);\n"
argc_maximum;
) else (
pr " if (argc < %d || argc > %d) {\n" argc_minimum argc_maximum;
pr " fprintf (stderr, _(\"%%s should have %%d-%%d parameter(s)\\n\"), cmd, %d, %d);\n"