Skip to content

Commit 6bb0920

Browse files
committed
Refactor printConfig to display aligned types and enum options
1 parent 7a7353c commit 6bb0920

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

meshtastic/__main__.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,18 +1201,31 @@ def setSimpleConfig(modem_preset):
12011201
def printConfig(config) -> None:
12021202
"""print configuration"""
12031203
objDesc = config.DESCRIPTOR
1204+
type_map = {5: "int", 8: "bool", 9: "str", 13: "int", 14: "enum"}
1205+
descriptions = {
1206+
"display.flip_screen": "orientation of oled screen",
1207+
"display.gps_format": "format of lat, lon coordinates"
1208+
}
12041209
for config_section in objDesc.fields:
12051210
if config_section.name != "version":
12061211
config = objDesc.fields_by_name.get(config_section.name)
12071212
print(f"{config_section.name}:")
12081213
names = []
12091214
for field in config.message_type.fields:
12101215
tmp_name = f"{config_section.name}.{field.name}"
1216+
lookup_name= tmp_name
1217+
12111218
if mt_config.camel_case:
12121219
tmp_name = meshtastic.util.snake_to_camel(tmp_name)
1213-
names.append(tmp_name)
1220+
f_type = type_map.get(field.type, "unknown")
1221+
desc = f"{descriptions[lookup_name]} || " if lookup_name in descriptions else ""
1222+
opts = " || options: True/False" if f_type == "bool" else ""
1223+
if f_type == "enum" and field.enum_type:
1224+
opts = f" || Options: {', '.join([v.name for v in field.enum_type.values])}"
1225+
1226+
names.append(f" {tmp_name:<45} # {desc}Type: {f_type}{opts}")
12141227
for temp_name in sorted(names):
1215-
print(f" {temp_name}")
1228+
print(temp_name)
12161229

12171230

12181231
def onNode(node) -> None:

0 commit comments

Comments
 (0)