From 6c10f1a1c08acd948e4aa7064656ccc24ddabfe3 Mon Sep 17 00:00:00 2001 From: Gal Pressman Date: Tue, 18 Nov 2025 16:32:08 +0200 Subject: [PATCH] tools: ynl: cli: Display enum values in --list-attrs output When listing attributes with --list-attrs, display the actual enum values for attributes that reference an enum type. # ./cli.py --family netdev --list-attrs dev-get [..] - xdp-features: u64 (enum: xdp-act) Flags: basic, redirect, ndo-xmit, xsk-zerocopy, hw-offload, rx-sg, ndo-xmit-sg Bitmask of enabled xdp-features. [..] Reviewed-by: Nimrod Oren Signed-off-by: Gal Pressman Link: https://patch.msgid.link/20251118143208.2380814-4-gal@nvidia.com Signed-off-by: Paolo Abeni --- tools/net/ynl/pyynl/cli.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/net/ynl/pyynl/cli.py b/tools/net/ynl/pyynl/cli.py index 6655ee61081a0..ff81ff0837646 100755 --- a/tools/net/ynl/pyynl/cli.py +++ b/tools/net/ynl/pyynl/cli.py @@ -48,7 +48,13 @@ def print_attr_list(ynl, attr_names, attr_set, indent=2): attr = attr_set.attrs[attr_name] attr_info = f'{prefix}- {attr_name}: {attr.type}' if 'enum' in attr.yaml: - attr_info += f" (enum: {attr.yaml['enum']})" + enum_name = attr.yaml['enum'] + attr_info += f" (enum: {enum_name})" + # Print enum values if available + if enum_name in ynl.consts: + const = ynl.consts[enum_name] + enum_values = list(const.entries.keys()) + attr_info += f"\n{prefix} {const.type.capitalize()}: {', '.join(enum_values)}" # Show nested attributes reference and recursively display them nested_set_name = None -- 2.47.3