X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=ggo.c;h=d8d56c03faa42e86a0c2d7862adb72a0b4603f04;hp=e3aa5794cee33815e7c04e1fd033a9a7c34bf244;hb=aa74a903545250506fd4c29791e6f4aef3a01c41;hpb=9f7a4958d65dd436dff90b37036ba01ce83066d5 diff --git a/ggo.c b/ggo.c index e3aa5794..d8d56c03 100644 --- a/ggo.c +++ b/ggo.c @@ -9,6 +9,7 @@ #include "para.h" #include "ggo.h" +#include "version.h" /** * Wrapper for printf() that exits on errors. @@ -32,20 +33,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 (flags & GPH_PRINT_NAME_VERSION) + printf_or_die("%s\n", version_single_line(help->prefix)); + 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); }