From: Michael Tremer Date: Sat, 14 Oct 2023 18:11:14 +0000 (+0000) Subject: cli: Add a doc string argument to the parser X-Git-Tag: 0.9.30~1521 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=50d2ca507e2d7201ddeef12c8616e24ffd78e720;p=pakfire.git cli: Add a doc string argument to the parser Signed-off-by: Michael Tremer --- diff --git a/src/cli/lib/build.c b/src/cli/lib/build.c index c63096d8d..afd9531b2 100644 --- a/src/cli/lib/build.c +++ b/src/cli/lib/build.c @@ -151,7 +151,7 @@ int cli_build(void* data, int argc, char* argv[]) { struct cli_config* cli_config = data; // Parse the command line - r = cli_parse(options, NULL, NULL, parse, argc, argv, &config); + r = cli_parse(options, NULL, NULL, NULL, parse, argc, argv, &config); if (r) goto ERROR; diff --git a/src/cli/lib/clean.c b/src/cli/lib/clean.c index 61c5fad90..1e56cb9f1 100644 --- a/src/cli/lib/clean.c +++ b/src/cli/lib/clean.c @@ -31,7 +31,7 @@ int cli_clean(void* data, int argc, char* argv[]) { struct cli_config* config = data; // Parse the command line - r = cli_parse(NULL, NULL, NULL, NULL, argc, argv, NULL); + r = cli_parse(NULL, NULL, NULL, NULL, NULL, argc, argv, NULL); if (r) goto ERROR; diff --git a/src/cli/lib/command.c b/src/cli/lib/command.c index ec9d15c2a..2a527f128 100644 --- a/src/cli/lib/command.c +++ b/src/cli/lib/command.c @@ -141,7 +141,8 @@ static error_t __command_parse(int key, char* arg, struct argp_state* state) { } int cli_parse(const struct argp_option* options, const struct command* commands, - const char* doc, command_parse parse, int argc, char** argv, void* data) { + const char* args_doc, const char* doc, + command_parse parse, int argc, char** argv, void* data) { int r; // Setup context @@ -156,7 +157,8 @@ int cli_parse(const struct argp_option* options, const struct command* commands, struct argp parser = { .options = options, .parser = __command_parse, - .args_doc = doc, + .args_doc = args_doc, + .doc = doc, }; int arg_index = 0; diff --git a/src/cli/lib/command.h b/src/cli/lib/command.h index d205ec891..b10df1e4c 100644 --- a/src/cli/lib/command.h +++ b/src/cli/lib/command.h @@ -35,6 +35,6 @@ struct command { }; int cli_parse(const struct argp_option* options, const struct command* commands, - const char* doc, command_parse parse, int argc, char** argv, void* data); + const char* args_doc, const char* doc, command_parse parse, int argc, char** argv, void* data); #endif /* PAKFIRE_CLI_COMMAND_H */ diff --git a/src/cli/pakfire-builder.c b/src/cli/pakfire-builder.c index fe152ad40..6b6348a90 100644 --- a/src/cli/pakfire-builder.c +++ b/src/cli/pakfire-builder.c @@ -80,7 +80,7 @@ static const struct command commands[] = { { NULL }, }; -const char* doc = +const char* args_doc = "build [OPTIONS...] MAKEFILES...\n" "clean\n" "dist MAKEFILES...\n" @@ -141,5 +141,5 @@ int main(int argc, char* argv[]) { }; // Parse the command line and run any commands - return cli_parse(options, commands, doc, parse, argc, argv, &config); + return cli_parse(options, commands, args_doc, NULL, parse, argc, argv, &config); }