2 * Helper functions for formatting --help program output.
4 * Copyright © 2021, 2023-2024 Nick Bowler
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
26 * Print an option string describing the short option character (if any),
27 * the long option name, and the argument name (if applicable). The argument
28 * name is localized (if NLS is enabled). If the string width is more than
29 * l columns, a newline is printed and 0 is returned. Otherwise, a newline
30 * is not printed and the string width (in columns) is returned.
32 int help_print_optstring(const struct option
*opt
, const char *argname
, int l
);
35 * Print an option description with each line indented. If opt is not NULL,
36 * then the string is first localized (if NLS is enabled) via pgettext_expr
37 * with the context set to opt->name. The first line will be indented by
38 * i-w spaces (to account for the cursor being in some other column), all
39 * other lines are indented by i spaces.
41 * The output always ends with a newline, regardless of whether or not the
42 * input string ends with a newline.
44 void help_print_desc(const struct option
*opt
, const char *desc
, int i
, int w
);
46 static inline void help_print_option(const struct option
*opt
,
47 const char *argname
, const char *desc
,
53 help_print_desc(opt
, desc
, w
,
54 help_print_optstring(opt
, argname
, w
-2));