[v5,8/9] buildtools/dpdk-cmdline-gen: support option strings
Checks
Commit Message
Add support to the commandline generator for option strings, where there
are only a limited number of acceptable values to be passed as a
parameter.
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
buildtools/dpdk-cmdline-gen.py | 7 +++++++
doc/guides/prog_guide/cmdline.rst | 6 +++++-
2 files changed, 12 insertions(+), 1 deletion(-)
@@ -73,6 +73,13 @@ def process_command(lineno, tokens, comment):
f"cmdline_parse_token_ipaddr_t cmd_{name}_{t_name}_tok =\n"
+ f"\tTOKEN_IPV4_INITIALIZER(struct cmd_{name}_result, {t_name});"
)
+ elif t_type.startswith("|") and t_type.endswith("|"):
+ result_struct.append(f"\tcmdline_fixed_string_t {t_name};")
+ t_val = f'"{t_type[1:-1].replace("|","#")}"'
+ initializers.append(
+ f"static cmdline_parse_token_string_t cmd_{name}_{t_name}_tok =\n"
+ + f"\tTOKEN_STRING_INITIALIZER(struct cmd_{name}_result, {t_name}, {t_val});"
+ )
else:
raise TypeError(f"Error line {lineno + 1}: unknown token type '{t_type}'")
token_list.append(f"cmd_{name}_{t_name}_tok")
@@ -62,7 +62,8 @@ The format of the list file must be:
* One command per line
-* Variable fields are prefixed by the type-name in angle-brackets, for example:
+* Variable fields are prefixed by the type-name, or "|"-delimited option-list, in angle-brackets.
+ For example:
* ``<STRING>message``
@@ -70,6 +71,8 @@ The format of the list file must be:
* ``<IP>src_ip``
+ * ``<|rx|tx|rxtx|>mode``
+
* The help text for a command is given in the form of a comment on the same line as the command
An example list file, with a variety of (unrelated) commands, is shown below::
@@ -79,6 +82,7 @@ An example list file, with a variety of (unrelated) commands, is shown below::
add <UINT16>x <UINT16>y # add x and y
echo <STRING>message # print message to screen
add socket <STRING>path # add unix socket with the given path
+ set mode <|rx|tx|>rxtx # set Rx-only or Tx-only mode
quit # close the application
Running the Generator Script