stardis-green

Post-processing of green functions
git clone git://git.meso-star.fr/stardis-green.git
Log | Files | Refs | README | LICENSE

commit 44ee69aa33c85744ffed5e7d0b66c724cd186b17
parent a5010e183446413733fe89ff9506bf60bbe3e8b5
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Sat, 27 Apr 2024 13:57:25 +0200

Complete rewriting of brief help

Remove the short descriptions of the options, as there is no specific
advantage in displaying them here rather than reading the man page. Only
the command synopsis is given to summarize the use of the command.  The
function is therefore renamed from "short_help" to "usage", which seems
closer to what it actually displays.

The command name is no longer one of its input argument and is defined
directly in the text. This apparently breaks the flexibility of
arbitrarily changing the program name, but it was neither envisaged nor
as simple and automated as one might first think. This name is
hard-coded into several parts of the project, from its man pages, to its
repository name, to the project prefix or README file. More than an
argument, it is above all a constant which, if modified, will require
several changes. On the other hand, assuming that this name is a
constant, we can edit the message displayed in the function, the object
of this commit, by aligning the program options with its name and
setting the line width to a maximum number of characters.

Diffstat:
Msrc/green-main.c | 2+-
Msrc/green-output.c | 53++++-------------------------------------------------
Msrc/green-output.h | 5++---
3 files changed, 7 insertions(+), 53 deletions(-)

diff --git a/src/green-main.c b/src/green-main.c @@ -59,7 +59,7 @@ main ERR(parse_args(argc, argv, &args)); if(args.mode & MODE_HELP) { - short_help(argv[0], stdout); + usage(stdout); goto exit; } diff --git a/src/green-output.c b/src/green-output.c @@ -52,57 +52,12 @@ print_version } void -short_help - (const char* prog, - FILE * stream) +usage(FILE * stream) { - const char* name; - ASSERT(stream && prog); - -#ifdef COMPILER_GCC - name = strrchr(prog, '/'); -#else - name = strrchr(prog, '\\'); -#endif - - name = name ? name + 1 : prog; - fprintf(stream, - "Usage: %s [OPTIONS]\n" - "\nUse a Green function created by stardis-app(1).\n" - "Refer to green(1) man page for more information.\n\n", - name); - - fprintf(stream, "\n -a <FILE>\n"); - fprintf(stream, " Apply a Green function using the variable settings " - "read from a file.\n"); - - fprintf(stream, "\n -e\n"); - fprintf(stream, " Use extended format to output Monte-Carlo results.\n"); - - fprintf(stream, "\n -g <FILE>\n"); - fprintf(stream, " Read a Green function from a file.\n"); - - fprintf(stream, "\n -h\n"); - fprintf(stream, " Print this help and exit.\n"); - - fprintf(stream, "\n -s <FILE>\n"); - fprintf(stream, " Create a summary of a Green function and write it to " - "a file.\n"); - - fprintf(stream, "\n -t NUM_OF_THREADS\n"); - fprintf(stream, " Hint on the number of threads.\n"); - - fprintf(stream, "\n -v\n"); - fprintf(stream, " Print version information and exit.\n"); - - fprintf(stream, "\n -V LEVEL\n"); - fprintf(stream, " Set the verbosity level.\n"); fprintf(stream, -"\nCopyright (C) 2020-2022, 2024 |Méso|Star> <contact@meso-star.com>.\n" -"stardis-green is free software released under the GNU GPL license, version 3 or later.\n" -"You are free to change or redistribute it under certain conditions\n" -"<http://gnu.org/licenses/gpl.html>.\n"); + "sgreen [-ehv] [-a arguments] [-g green] [-s summary] [-t threads_count]\n" + " [-V verbosity_level]\n"); } void @@ -533,7 +488,7 @@ dump_green_info local_count++; } if(local_count) fprintf(stream, "</table>\n"); - + /* S-S connection table */ local_count = 0; FOR_EACH(i, 0, green->header.description_count) { diff --git a/src/green-output.h b/src/green-output.h @@ -27,9 +27,8 @@ print_version (FILE* stream); void -short_help - (const char* prog, - FILE* stream); +usage + (FILE* stream); void green_print_result