gettext-runtime: Improve --help output.

* gettext-runtime/src/gettext.c (usage): Add section title
"Options and arguments".
* gettext-runtime/src/ngettext.c (usage): Likewise.
* gettext-runtime/doc/rt-gettext.texi: Add section titles
"Options and arguments" and "Informative output".
* gettext-runtime/doc/rt-ngettext.texi: Likewise.
This commit is contained in:
Bruno Haible 2025-06-25 04:15:58 +02:00
parent 338edb5ccc
commit adf6e5709b
4 changed files with 89 additions and 75 deletions

View File

@ -1,5 +1,5 @@
@c This file is part of the GNU gettext manual.
@c Copyright (C) 1995-2019 Free Software Foundation, Inc.
@c Copyright (C) 1995-2025 Free Software Foundation, Inc.
@c See the file gettext.texi for copying conditions.
@pindex gettext
@ -13,7 +13,7 @@ gettext [@var{option}] -s [@var{msgid}]...
The @code{gettext} program displays the native language translation of a
textual message.
@noindent @strong{Arguments}
@noindent @strong{Options and arguments}
@table @samp
@item -c @var{context}
@ -43,26 +43,31 @@ interpreted like the System V @samp{echo} program did.
This option is only for compatibility with the @samp{echo} program or shell
built-in. It has no effect.
@item -n
@opindex -n@r{, @code{gettext} option}
This option has only an effect if the @code{-s} option is given. It
suppresses the additional newline at the end.
@item [@var{textdomain}] @var{msgid}
Retrieve translated message corresponding to @var{msgid} from @var{textdomain}.
@end table
@noindent @strong{Informative output}
@table @samp
@item -h
@itemx --help
@opindex -h@r{, @code{gettext} option}
@opindex --help@r{, @code{gettext} option}
Display this help and exit.
@item -n
@opindex -n@r{, @code{gettext} option}
This option has only an effect if the @code{-s} option is given. It
suppresses the additional newline at the end.
@item -V
@itemx --version
@opindex -V@r{, @code{gettext} option}
@opindex --version@r{, @code{gettext} option}
Output version information and exit.
@item [@var{textdomain}] @var{msgid}
Retrieve translated message corresponding to @var{msgid} from @var{textdomain}.
@end table
If the @var{textdomain} parameter is not given, the domain is determined from

View File

@ -1,5 +1,5 @@
@c This file is part of the GNU gettext manual.
@c Copyright (C) 1995-2019 Free Software Foundation, Inc.
@c Copyright (C) 1995-2025 Free Software Foundation, Inc.
@c See the file gettext.texi for copying conditions.
@pindex ngettext
@ -12,7 +12,7 @@ ngettext [@var{option}] [@var{textdomain}] @var{msgid} @var{msgid-plural} @var{c
The @code{ngettext} program displays the native language translation of a
textual message whose grammatical form depends on a number.
@noindent @strong{Arguments}
@noindent @strong{Options and arguments}
@table @samp
@item -c @var{context}
@ -42,6 +42,20 @@ interpreted like the System V @samp{echo} program did.
This option is only for compatibility with the @samp{gettext} program. It has
no effect.
@item @var{textdomain}
Retrieve translated message from @var{textdomain}.
@item @var{msgid} @var{msgid-plural}
Translate @var{msgid} (English singular) / @var{msgid-plural} (English plural).
@item @var{count}
Choose singular/plural form based on this value.
@end table
@noindent @strong{Informative output}
@table @samp
@item -h
@itemx --help
@opindex -h@r{, @code{ngettext} option}
@ -54,15 +68,6 @@ Display this help and exit.
@opindex --version@r{, @code{ngettext} option}
Output version information and exit.
@item @var{textdomain}
Retrieve translated message from @var{textdomain}.
@item @var{msgid} @var{msgid-plural}
Translate @var{msgid} (English singular) / @var{msgid-plural} (English plural).
@item @var{count}
Choose singular/plural form based on this value.
@end table
If the @var{textdomain} parameter is not given, the domain is determined from

View File

@ -96,36 +96,36 @@ main (int argc, char *argv[])
while ((optchar = getopt_long (argc, argv, "+c:d:eEhnsV", long_options, NULL))
!= EOF)
switch (optchar)
{
case '\0': /* Long option. */
break;
case 'c':
context = optarg;
break;
case 'd':
domain = optarg;
break;
case 'e':
do_expand = true;
break;
case 'E':
/* Ignore. Just for compatibility. */
break;
case 'h':
do_help = true;
break;
case 'n':
inhibit_added_newline = true;
break;
case 's':
do_shell = true;
break;
case 'V':
do_version = true;
break;
default:
usage (EXIT_FAILURE);
}
{
case '\0': /* Long option. */
break;
case 'c':
context = optarg;
break;
case 'd':
domain = optarg;
break;
case 'e':
do_expand = true;
break;
case 'E':
/* Ignore. Just for compatibility. */
break;
case 'h':
do_help = true;
break;
case 'n':
inhibit_added_newline = true;
break;
case 's':
do_shell = true;
break;
case 'V':
do_version = true;
break;
default:
usage (EXIT_FAILURE);
}
/* Version information is requested. */
if (do_version)
@ -258,6 +258,8 @@ or: %s [OPTION] -s [MSGID]...\n\
printf (_("\
Display native language translation of a textual message.\n"));
printf ("\n");
printf (_("\
Options and arguments:\n"));
/* xgettext: no-wrap */
printf (_("\
-d, --domain=TEXTDOMAIN retrieve translated messages from TEXTDOMAIN\n"));

View File

@ -93,30 +93,30 @@ main (int argc, char *argv[])
while ((optchar = getopt_long (argc, argv, "+c:d:eEhV", long_options, NULL))
!= EOF)
switch (optchar)
{
case '\0': /* Long option. */
break;
case 'c':
context = optarg;
break;
case 'd':
domain = optarg;
break;
case 'e':
do_expand = true;
break;
case 'E':
/* Ignore. Just for compatibility. */
break;
case 'h':
do_help = true;
break;
case 'V':
do_version = true;
break;
default:
usage (EXIT_FAILURE);
}
{
case '\0': /* Long option. */
break;
case 'c':
context = optarg;
break;
case 'd':
domain = optarg;
break;
case 'e':
do_expand = true;
break;
case 'E':
/* Ignore. Just for compatibility. */
break;
case 'h':
do_help = true;
break;
case 'V':
do_version = true;
break;
default:
usage (EXIT_FAILURE);
}
/* Version information is requested. */
if (do_version)
@ -226,6 +226,8 @@ Usage: %s [OPTION] [TEXTDOMAIN] MSGID MSGID-PLURAL COUNT\n\
Display native language translation of a textual message whose grammatical\n\
form depends on a number.\n"));
printf ("\n");
printf (_("\
Options and arguments:\n"));
/* xgettext: no-wrap */
printf (_("\
-d, --domain=TEXTDOMAIN retrieve translated message from TEXTDOMAIN\n"));