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.richard...@intel.com>
---
 buildtools/dpdk-cmdline-gen.py    | 7 +++++++
 doc/guides/prog_guide/cmdline.rst | 7 +++++++
 2 files changed, 14 insertions(+)

diff --git a/buildtools/dpdk-cmdline-gen.py b/buildtools/dpdk-cmdline-gen.py
index c208121363..8922bb5fc3 100755
--- a/buildtools/dpdk-cmdline-gen.py
+++ b/buildtools/dpdk-cmdline-gen.py
@@ -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")
diff --git a/doc/guides/prog_guide/cmdline.rst 
b/doc/guides/prog_guide/cmdline.rst
index 0b96b770e2..42e6a54bf4 100644
--- a/doc/guides/prog_guide/cmdline.rst
+++ b/doc/guides/prog_guide/cmdline.rst
@@ -70,6 +70,12 @@ The format of the list file must be:
 
   * ``<IP>src_ip``
 
+* Variable fields, which take their values from a list of options,
+  have the comma-separated option list placed in braces, rather than a the 
type name.
+  For example,
+
+  * ``<(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 +85,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
-- 
2.39.2

Reply via email to