]> git.ipfire.org Git - pakfire.git/commitdiff
cli: table: Add option to print Yes/No
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 1 Jul 2025 16:13:58 +0000 (16:13 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 1 Jul 2025 16:13:58 +0000 (16:13 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/cli/lib/table.c
src/cli/lib/table.h

index b21ac834deb569fa80606ea1b0c4c8472bee3b56..5236c2952551016dd1686b8c4ecad601697de050 100644 (file)
@@ -195,6 +195,13 @@ int cli_table_add_row(cli_table* self, ...) {
                        case CLI_TABLE_FLOAT:
                                r = pakfire_string_format(buffer, "%f", va_arg(args, double));
                                break;
+
+                       case CLI_TABLE_YESNO:
+                               if (va_arg(args, int))
+                                       r = pakfire_string_format(buffer, "%s", "Yes");
+                               else
+                                       r = pakfire_string_format(buffer, "%s", "No");
+                               break;
                }
 
                // Break if we could not format the argument
index bda3d41775d0803fcc7c281b90463aacd4b6ae40..c75f9f7e5e8b9d9dfc07520ce05e46ae7bce1134 100644 (file)
@@ -33,6 +33,7 @@ typedef enum {
        CLI_TABLE_STRING,
        CLI_TABLE_INTEGER,
        CLI_TABLE_FLOAT,
+       CLI_TABLE_YESNO,
 } cli_table_col_type;
 
 typedef enum {