[PATCH 4/6] cmdline: add explicit help function for bool type
Bruce Richardson
bruce.richardson at intel.com
Thu May 7 16:59:47 CEST 2026
Rather than using the string help output, have a specific boolean help
output that prints out on|off as the options.
Signed-off-by: Bruce Richardson <bruce.richardson at intel.com>
---
lib/cmdline/cmdline_parse_bool.c | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/lib/cmdline/cmdline_parse_bool.c b/lib/cmdline/cmdline_parse_bool.c
index a3f7adab58..d5d5499531 100644
--- a/lib/cmdline/cmdline_parse_bool.c
+++ b/lib/cmdline/cmdline_parse_bool.c
@@ -13,13 +13,17 @@
#include "cmdline_parse.h"
#include "cmdline_parse_bool.h"
+static int
+cmdline_get_help_bool(cmdline_parse_token_hdr_t *tk, char *dstbuf,
+ unsigned int size);
+
RTE_EXPORT_EXPERIMENTAL_SYMBOL(cmdline_token_bool_ops, 25.03)
struct cmdline_token_ops cmdline_token_bool_ops = {
.parse = cmdline_parse_bool,
.complete_get_nb = NULL,
.complete_get_elt = NULL,
- .get_help = cmdline_get_help_string,
+ .get_help = cmdline_get_help_bool,
};
static cmdline_parse_token_string_t cmd_parse_token_bool = {
@@ -32,6 +36,18 @@ static cmdline_parse_token_string_t cmd_parse_token_bool = {
}
};
+/* get help for bool token */
+static int
+cmdline_get_help_bool(__rte_unused cmdline_parse_token_hdr_t *tk,
+ char *dstbuf, unsigned int size)
+{
+ if (dstbuf == NULL || size == 0)
+ return -1;
+
+ strlcpy(dstbuf, "on|off", size);
+ return 0;
+}
+
/* parse string to bool */
int
cmdline_parse_bool(__rte_unused cmdline_parse_token_hdr_t *tk, const char *srcbuf, void *res,
--
2.51.0
More information about the dev
mailing list