Skip to content
Snippets Groups Projects
Commit 35b825a8 authored by Peter W. Draper's avatar Peter W. Draper
Browse files

Format options help into indented paragraphs

parent a32ce837
Branches
Tags
1 merge request!689Add GNU style long command line arguments
......@@ -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
......
......@@ -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),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment