From: Michael Tremer Date: Thu, 19 Oct 2023 21:14:13 +0000 (+0000) Subject: cli: Pass argp state to the parse callback X-Git-Tag: 0.9.30~1437 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d673ca6ce915b3b3d5847212c8c63309247b3273;p=pakfire.git cli: Pass argp state to the parse callback Signed-off-by: Michael Tremer --- diff --git a/src/cli/lib/build.c b/src/cli/lib/build.c index afd9531b2..59b559a46 100644 --- a/src/cli/lib/build.c +++ b/src/cli/lib/build.c @@ -62,7 +62,7 @@ static struct argp_option options[] = { { NULL }, }; -static error_t parse(int key, char* arg, void* data) { +static error_t parse(int key, char* arg, struct argp_state* state, void* data) { struct config* config = data; switch (key) { diff --git a/src/cli/lib/command.c b/src/cli/lib/command.c index 3adf0365f..f224ab7f9 100644 --- a/src/cli/lib/command.c +++ b/src/cli/lib/command.c @@ -99,7 +99,7 @@ static error_t __command_parse(int key, char* arg, struct argp_state* state) { if (!ctx->parse) return ARGP_ERR_UNKNOWN; - return ctx->parse(key, arg, ctx->data); + return ctx->parse(key, arg, state, ctx->data); } switch (key) { @@ -155,7 +155,7 @@ static error_t __command_parse(int key, char* arg, struct argp_state* state) { if (!ctx->parse) return ARGP_ERR_UNKNOWN; - return ctx->parse(key, arg, ctx->data); + return ctx->parse(key, arg, state, ctx->data); } return 0; diff --git a/src/cli/lib/command.h b/src/cli/lib/command.h index 63a28baca..c03e34fff 100644 --- a/src/cli/lib/command.h +++ b/src/cli/lib/command.h @@ -23,7 +23,7 @@ #include -typedef error_t (*command_parse)(int key, char* arg, void* data); +typedef error_t (*command_parse)(int key, char* arg, struct argp_state* state, void* data); struct command { const char* verb; diff --git a/src/cli/lib/dist.c b/src/cli/lib/dist.c index e4bf955c0..5e1cad1af 100644 --- a/src/cli/lib/dist.c +++ b/src/cli/lib/dist.c @@ -41,7 +41,7 @@ struct config { unsigned int num_makefiles; }; -static error_t parse(int key, char* arg, void* data) { +static error_t parse(int key, char* arg, struct argp_state* state, void* data) { struct config* config = data; switch (key) { diff --git a/src/cli/lib/image_create.c b/src/cli/lib/image_create.c index 595848b18..cc2eb19d4 100644 --- a/src/cli/lib/image_create.c +++ b/src/cli/lib/image_create.c @@ -36,7 +36,7 @@ static const char* args_doc = "image create TYPE PATH"; static const char* doc = "Creates images"; -static error_t parse(int key, char* arg, void* data) { +static error_t parse(int key, char* arg, struct argp_state* state, void* data) { struct config* config = data; switch (key) { diff --git a/src/cli/lib/info.c b/src/cli/lib/info.c index 75316f385..58a016d75 100644 --- a/src/cli/lib/info.c +++ b/src/cli/lib/info.c @@ -54,7 +54,7 @@ static struct argp_option options[] = { { NULL }, }; -static error_t parse(int key, char* arg, void* data) { +static error_t parse(int key, char* arg, struct argp_state* state, void* data) { struct config* config = data; switch (key) { diff --git a/src/cli/lib/provides.c b/src/cli/lib/provides.c index 0e625b20e..605893755 100644 --- a/src/cli/lib/provides.c +++ b/src/cli/lib/provides.c @@ -38,7 +38,7 @@ struct config { unsigned int num_patterns; }; -static error_t parse(int key, char* arg, void* data) { +static error_t parse(int key, char* arg, struct argp_state* state, void* data) { struct config* config = data; switch (key) { diff --git a/src/cli/lib/repo_compose.c b/src/cli/lib/repo_compose.c index cccee6666..47cff9b8b 100644 --- a/src/cli/lib/repo_compose.c +++ b/src/cli/lib/repo_compose.c @@ -50,7 +50,7 @@ static struct argp_option options[] = { { NULL }, }; -static error_t parse(int key, char* arg, void* data) { +static error_t parse(int key, char* arg, struct argp_state* state, void* data) { struct config* config = data; switch (key) { diff --git a/src/cli/lib/requires.c b/src/cli/lib/requires.c index 5b0703399..84b958022 100644 --- a/src/cli/lib/requires.c +++ b/src/cli/lib/requires.c @@ -38,7 +38,7 @@ struct config { unsigned int num_patterns; }; -static error_t parse(int key, char* arg, void* data) { +static error_t parse(int key, char* arg, struct argp_state* state, void* data) { struct config* config = data; switch (key) { diff --git a/src/cli/lib/search.c b/src/cli/lib/search.c index 840ec2ebb..fa7fe810a 100644 --- a/src/cli/lib/search.c +++ b/src/cli/lib/search.c @@ -38,7 +38,7 @@ struct config { unsigned int num_patterns; }; -static error_t parse(int key, char* arg, void* data) { +static error_t parse(int key, char* arg, struct argp_state* state, void* data) { struct config* config = data; switch (key) { diff --git a/src/cli/lib/shell.c b/src/cli/lib/shell.c index 94c1e5b22..7ad2d971a 100644 --- a/src/cli/lib/shell.c +++ b/src/cli/lib/shell.c @@ -51,7 +51,7 @@ static struct argp_option options[] = { { NULL }, }; -static error_t parse(int key, char* arg, void* data) { +static error_t parse(int key, char* arg, struct argp_state* state, void* data) { struct config* config = data; switch (key) { diff --git a/src/cli/lib/upload_create.c b/src/cli/lib/upload_create.c index fc0309b3a..f22c7ad0c 100644 --- a/src/cli/lib/upload_create.c +++ b/src/cli/lib/upload_create.c @@ -37,7 +37,7 @@ struct config { unsigned int num_files; }; -static error_t parse(int key, char* arg, void* data) { +static error_t parse(int key, char* arg, struct argp_state* state, void* data) { struct config* config = data; switch (key) { diff --git a/src/cli/pakfire-builder.c b/src/cli/pakfire-builder.c index 96cc6a360..75fb65a42 100644 --- a/src/cli/pakfire-builder.c +++ b/src/cli/pakfire-builder.c @@ -93,7 +93,7 @@ const char* args_doc = "shell [OPTIONS...]\n" "search [OPTIONS...] PATTERN"; -static error_t parse(int key, char* arg, void* data) { +static error_t parse(int key, char* arg, struct argp_state* state, void* data) { struct cli_config* config = data; switch (key) { diff --git a/src/cli/pakfire-client.c b/src/cli/pakfire-client.c index 59877d735..c39c643e1 100644 --- a/src/cli/pakfire-client.c +++ b/src/cli/pakfire-client.c @@ -48,7 +48,7 @@ static struct argp_option options[] = { { NULL }, }; -static error_t parse(int key, char* arg, void* data) { +static error_t parse(int key, char* arg, struct argp_state* state, void* data) { struct pakfire_ctx* ctx = data; switch (key) { diff --git a/src/cli/pakfire.c b/src/cli/pakfire.c index cb499ce13..c1124cae9 100644 --- a/src/cli/pakfire.c +++ b/src/cli/pakfire.c @@ -88,7 +88,7 @@ static const struct command commands[] = { { NULL }, }; -static error_t parse(int key, char* arg, void* data) { +static error_t parse(int key, char* arg, struct argp_state* state, void* data) { struct cli_config* config = data; switch (key) {