Skip to content

Commit 7ef64d4

Browse files
committed
Print options
1 parent 363aa99 commit 7ef64d4

17 files changed

+66
-60
lines changed

meshtastic/__main__.py

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,6 @@ def getPref(config, comp_name):
7272
pref = config_type.message_type.fields_by_name.get(snake_name)
7373

7474
if (not pref) or (not config_type):
75-
print(f"Not found. Choices in sorted order are:")
76-
for config_section in objDesc.fields:
77-
config = objDesc.fields_by_name.get(config_section.name)
78-
if not config:
79-
names = []
80-
for field in config.fields:
81-
tmp_name = f'{config_section.name}.{field.name}'
82-
if Globals.getInstance().get_camel_case():
83-
tmp_name = meshtastic.util.snake_to_camel(tmp_name)
84-
names.append(tmp_name)
85-
for temp_name in sorted(names):
86-
print(f" {temp_name}")
87-
8875
return False
8976

9077
# read the value
@@ -380,6 +367,9 @@ def onConnected(interface):
380367
print(f"{node.localConfig.__class__.__name__} and {node.moduleConfig.__class__.__name__} do not have an attribute {pref[0]}.")
381368
else:
382369
print(f"{node.localConfig.__class__.__name__} and {node.moduleConfig.__class__.__name__} do not have attribute {pref[0]}.")
370+
print("Choices are...")
371+
printConfig(node.localConfig)
372+
printConfig(node.moduleConfig)
383373

384374
if args.configure:
385375
with open(args.configure[0], encoding='utf8') as file:
@@ -586,8 +576,11 @@ def setSimpleConfig(modem_preset):
586576
print(f"{localConfig.__class__.__name__} and {moduleConfig.__class__.__name__} do not have an attribute {pref[0]}.")
587577
else:
588578
print(f"{localConfig.__class__.__name__} and {moduleConfig.__class__.__name__} do not have attribute {pref[0]}.")
589-
590-
print("Completed getting preferences")
579+
print("Choices are...")
580+
printConfig(localConfig)
581+
printConfig(moduleConfig)
582+
else:
583+
print("Completed getting preferences")
591584

592585
if args.nodes:
593586
closeNow = True
@@ -619,6 +612,20 @@ def setSimpleConfig(modem_preset):
619612
print(f"Aborting due to: {ex}")
620613
interface.close() # close the connection now, so that our app exits
621614

615+
def printConfig(config):
616+
objDesc = config.DESCRIPTOR
617+
for config_section in objDesc.fields:
618+
if config_section.name != "version":
619+
config = objDesc.fields_by_name.get(config_section.name)
620+
print(f"{config_section.name}:")
621+
names = []
622+
for field in config.message_type.fields:
623+
tmp_name = f'{config_section.name}.{field.name}'
624+
if Globals.getInstance().get_camel_case():
625+
tmp_name = meshtastic.util.snake_to_camel(tmp_name)
626+
names.append(tmp_name)
627+
for temp_name in sorted(names):
628+
print(f" {temp_name}")
622629

623630
def onNode(node):
624631
"""Callback invoked when the node DB changes"""
@@ -825,8 +832,7 @@ def initParser():
825832

826833
parser.add_argument(
827834
"--get", help=("Get a preferences field. Use an invalid field such as '0' to get a list of all fields."
828-
" Can use either snake_case or camelCase format. (ex: 'ls_secs' or 'lsSecs')"),
829-
nargs=1, action='append')
835+
" Can use either snake_case or camelCase format. (ex: 'ls_secs' or 'lsSecs')"), action='append')
830836

831837
parser.add_argument(
832838
"--set", help="Set a preferences field. Can use either snake_case or camelCase format. (ex: 'ls_secs' or 'lsSecs')", nargs=2, action='append')

meshtastic/admin_pb2.py

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

meshtastic/apponly_pb2.py

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

meshtastic/cannedmessages_pb2.py

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

meshtastic/channel_pb2.py

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)