2 * Copyright (C) 2008-2013 Andre Noll <maan@systemlinux.org>
4 * Licensed under the GPL v2. For licencing details see COPYING.
7 /** \file ggo.c Function for printing help. */
15 * Wrapper for printf() that exits on errors.
17 * \param fmt Usual format string.
19 __printf_1_2
int printf_or_die(const char *fmt
, ...)
25 ret
= vprintf(fmt
, argp
);
33 * Print one of the two given help texts.
35 * \param help contains the help texts.
36 * \param flags What to print, see \ref ggo_print_help_flags.
38 void ggo_print_help(struct ggo_help
*help
, unsigned flags
)
42 if (flags
& GPH_PRINT_NAME_VERSION
)
43 printf_or_die("%s\n", version_single_line(help
->prefix
));
44 if (help
->usage
&& (flags
& GPH_PRINT_USAGE
))
45 printf_or_die("\n%s\n", help
->usage
);
46 if (help
->description
&& (flags
& GPH_PRINT_DESCRIPTION
))
47 printf_or_die("\n%s\n", help
->description
);
49 if (flags
& GPH_DETAILED
)
50 p
= help
->detailed_help
;
56 printf_or_die("%s\n", *p
);