Skip to content

Commit 3db64f7

Browse files
authored
Merge pull request #387 from meshtastic/fun-fun
Print available options
2 parents 696fa28 + 7ef64d4 commit 3db64f7

17 files changed

+66
-47
lines changed

meshtastic/__main__.py

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,9 @@ def onConnected(interface):
367367
print(f"{node.localConfig.__class__.__name__} and {node.moduleConfig.__class__.__name__} do not have an attribute {pref[0]}.")
368368
else:
369369
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)
370373

371374
if args.configure:
372375
with open(args.configure[0], encoding='utf8') as file:
@@ -573,8 +576,11 @@ def setSimpleConfig(modem_preset):
573576
print(f"{localConfig.__class__.__name__} and {moduleConfig.__class__.__name__} do not have an attribute {pref[0]}.")
574577
else:
575578
print(f"{localConfig.__class__.__name__} and {moduleConfig.__class__.__name__} do not have attribute {pref[0]}.")
576-
577-
print("Completed getting preferences")
579+
print("Choices are...")
580+
printConfig(localConfig)
581+
printConfig(moduleConfig)
582+
else:
583+
print("Completed getting preferences")
578584

579585
if args.nodes:
580586
closeNow = True
@@ -606,6 +612,20 @@ def setSimpleConfig(modem_preset):
606612
print(f"Aborting due to: {ex}")
607613
interface.close() # close the connection now, so that our app exits
608614

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}")
609629

610630
def onNode(node):
611631
"""Callback invoked when the node DB changes"""
@@ -812,8 +832,7 @@ def initParser():
812832

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

818837
parser.add_argument(
819838
"--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)