diff options
| author | Gal Pressman <gal@nvidia.com> | 2025-11-18 16:32:08 +0200 |
|---|---|---|
| committer | Paolo Abeni <pabeni@redhat.com> | 2025-11-20 15:43:04 +0100 |
| commit | 6c10f1a1c08acd948e4aa7064656ccc24ddabfe3 (patch) | |
| tree | 23c60b95f8c71b52ea380661b1c013ff02b61744 | |
| parent | bc1bc1b357cdae75d17ecde0aabe1b95ce08c7a5 (diff) | |
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 <noren@nvidia.com>
Signed-off-by: Gal Pressman <gal@nvidia.com>
Link: https://patch.msgid.link/20251118143208.2380814-4-gal@nvidia.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
| -rwxr-xr-x | tools/net/ynl/pyynl/cli.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/tools/net/ynl/pyynl/cli.py b/tools/net/ynl/pyynl/cli.py index 6655ee61081a..ff81ff083764 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 |
