X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=ggo.c;h=99171c73457d150cb2f4b193f5fe20df0025e662;hp=e3aa5794cee33815e7c04e1fd033a9a7c34bf244;hb=6bcd10bc4ada11a04bc2b7425afe5a8855592cd2;hpb=533b0303c27fb9ba098bb72e30f41f0939b2dbd2 diff --git a/ggo.c b/ggo.c index e3aa5794..99171c73 100644 --- a/ggo.c +++ b/ggo.c @@ -9,11 +9,15 @@ #include "para.h" #include "ggo.h" +#include "version.h" /** * Wrapper for printf() that exits on errors. * * \param fmt Usual format string. + * + * \return The return value of the underlying (successful) call to vprintf(3), + * i.e. the number of characters printed, excluding the terminating null byte. */ __printf_1_2 int printf_or_die(const char *fmt, ...) { @@ -32,20 +36,25 @@ __printf_1_2 int printf_or_die(const char *fmt, ...) * Print one of the two given help texts. * * \param help contains the help texts. - * \param detailed_help Whether to print the detailed help text. + * \param flags What to print, see \ref ggo_print_help_flags. */ -void ggo_print_help(struct ggo_help *help, int detailed_help) +void ggo_print_help(struct ggo_help *help, unsigned flags) { const char **p; - if (!help) - return; - if (detailed_help) + if (help->purpose && (flags & GPH_PRINT_NAME_PURPOSE)) + printf_or_die("para_%s - %s\n", help->prefix, help->purpose); + if (help->usage && (flags & GPH_PRINT_USAGE)) + printf_or_die("\n%s\n", help->usage); + if (help->description && (flags & GPH_PRINT_DESCRIPTION)) + printf_or_die("\n%s\n", help->description); + printf_or_die("\n"); + if (flags & GPH_DETAILED) p = help->detailed_help; else p = help->short_help; if (!p) return; for (; *p; p++) - printf_or_die("\t%s\n", *p); + printf_or_die("%s\n", *p); }