From fddec42f7e3fcc7e5e013f0ed44abbec75d6444a Mon Sep 17 00:00:00 2001 From: Artem Goncharov Date: Tue, 3 Dec 2024 11:20:27 +0100 Subject: [PATCH] Add `status` structable macros for alternative field Some resources uses `state` or `operating_status` as a sort of `status` property. Set `status` StructTable marcros for such fields so that output coloring use those fields. Change-Id: I1c1faa0f69e1d22b6230db2df90a981ca496e643 --- codegenerator/rust_cli.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/codegenerator/rust_cli.py b/codegenerator/rust_cli.py index bc95c04..21d1d23 100644 --- a/codegenerator/rust_cli.py +++ b/codegenerator/rust_cli.py @@ -34,6 +34,7 @@ BASIC_FIELDS = [ "uuid", "state", "status", + "operating_status", ] @@ -276,6 +277,16 @@ class StructFieldResponse(common_rust.StructField): # there is at least "id" field existing in the struct OR the # field is not in the first 10 macros.add("wide") + if ( + self.local_name == "state" + and "status" not in struct.fields.keys() + ): + macros.add("status") + elif ( + self.local_name == "operating_status" + and "status" not in struct.fields.keys() + ): + macros.add("status") if self.data_type.type_hint in [ "Value", "Option",