2 * Copyright © 2021, 2023 Nick Bowler
4 * Helper functions for formatting --help program output.
6 * License WTFPL2: Do What The Fuck You Want To Public License, version 2.
7 * This is free software: you are free to do what the fuck you want to.
8 * There is NO WARRANTY, to the extent permitted by law.
17 * Print an option string describing the short option character (if any),
18 * the long option name, and the argument name (if applicable). The argument
19 * name is localized (if NLS is enabled). If the string width is more than
20 * l columns, a newline is printed and 0 is returned. Otherwise, a newline
21 * is not printed and the string width (in columns) is returned.
23 int help_print_optstring(const struct option *opt, const char *argname, int l);
26 * Print an option description with each line indented. If opt is not NULL,
27 * then the string is first localized (if NLS is enabled) via pgettext_expr
28 * with the context set to opt->name. The first line will be indented by
29 * i-w spaces (to account for the cursor being in some other column), all
30 * other lines are indented by i spaces.
32 * The output always ends with a newline, regardless of whether or not the
33 * input string ends with a newline.
35 void help_print_desc(const struct option *opt, const char *desc, int i, int w);
37 static inline void help_print_option(const struct option *opt,
38 const char *argname, const char *desc,
44 help_print_desc(opt, desc, w,
45 help_print_optstring(opt, argname, w-2));