exported.sh: Work around DJGPP shell redirection bug.
[dxcommon.git] / src / help.h
bloba78bc59c0b6fc48953d8e556a12d0b8ef34bc3c1
1 /*
2 * Copyright © 2021 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.
9 */
11 #ifndef DX_HELP_H_
12 #define DX_HELP_H_
14 struct option;
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 void help_print_desc(const struct option *opt, const char *desc, int i, int w);
34 static inline void help_print_option(const struct option *opt,
35 const char *argname, const char *desc,
36 int w)
38 if (w < 2)
39 w = 2;
41 help_print_desc(opt, desc, w,
42 help_print_optstring(opt, argname, w-2));
45 #endif