]> git.ipfire.org Git - pakfire.git/commitdiff
cli: Add a doc string argument to the parser
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 14 Oct 2023 18:11:14 +0000 (18:11 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 14 Oct 2023 18:11:14 +0000 (18:11 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/cli/lib/build.c
src/cli/lib/clean.c
src/cli/lib/command.c
src/cli/lib/command.h
src/cli/pakfire-builder.c

index c63096d8d04443fb149340ea69c6e7efd52bc672..afd9531b2da6eecfe43a03d44b0a6d544ab84e21 100644 (file)
@@ -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;
 
index 61c5fad906ab91e450b130af08860ed073b365a4..1e56cb9f1a1f6d07c2145172881ac435dffc482b 100644 (file)
@@ -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;
 
index ec9d15c2a05ebe2d9c2346f076bafef8ff444804..2a527f128d8f1e4c63832608335c77a11c9704ac 100644 (file)
@@ -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;
 
index d205ec891c673ee598947fe21dae0c02a717ed5f..b10df1e4ccd961c944cdfc7783b986e16f35707f 100644 (file)
@@ -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 */
index fe152ad40d115ed377b76a31f2598d8aa252b6e7..6b6348a90cd67584a63499554f3c75b8a3fdc545 100644 (file)
@@ -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);
 }