diff --git a/argparse/argparse.c b/argparse/argparse.c index f53184bab1d9278bf38d0445b7136c8424e8a573..82bdc7d3d0d398f249e8234ce0965c548339feb3 100644 --- a/argparse/argparse.c +++ b/argparse/argparse.c @@ -368,7 +368,30 @@ argparse_usage(struct argparse *self) fputc('\n', stdout); pad = usage_opts_width; } - fprintf(stdout, "%*s%s\n", pad + 2, "", options->help); + if (options->help != NULL && strlen(options->help) > 0) { + char *str = strdup(options->help); + char *token = strtok(str, " "); + fprintf(stdout, "%*s%s ", pad + 2, "", token); + int count = strlen(token); + int dangling = 1; + while ((token = strtok(NULL, " ")) != NULL) { + if (count == 0) { + fprintf(stdout, "%*s", (int)pos + pad + 2, ""); + dangling = 1; + } + printf("%s ", token); + count += strlen(token); + if (count > 30) { + count = 0; + fprintf(stdout, "\n"); + dangling = 0; + } + } + if (dangling) fprintf(stdout, "\n"); + } else { + fprintf(stdout, "\n"); + } + } // print epilog diff --git a/examples/main.c b/examples/main.c index 1147794d8b9ce15a57ba68f2e1cb62094cb97bd0..b35cd7e54d0d501f3258927c1ff468d63e0d1cea 100644 --- a/examples/main.c +++ b/examples/main.c @@ -198,7 +198,7 @@ int main(int argc, char *argv[]) { "Pin runners using processor affinity.", NULL, 0, 0), OPT_BOOLEAN('d', "dry-run", &dry_run, "Dry run. Read the parameter file, allocates memory but " - "does not read the particles from ICs.\t\nExits before the " + "does not read the particles from ICs. Exits before the " "start of time integration. Checks the validity of " "parameters and IC files as well as memory limits.", NULL, 0, 0),