Skip to content

Commit

Permalink
nargs='?' is awesome! get rid of ble_dest.
Browse files Browse the repository at this point in the history
  • Loading branch information
geeksville committed Jun 30, 2024
1 parent 7e44069 commit 5c2851d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"request": "launch",
"module": "meshtastic",
"justMyCode": false,
"args": ["--ble", "--ble-dest", "Meshtastic_9f6e"]
"args": ["--ble", "Meshtastic_9f6e"]
},
{
"name": "meshtastic BLE scan",
Expand Down
12 changes: 4 additions & 8 deletions meshtastic/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1046,7 +1046,7 @@ def common():
print(f"Found: name='{x.name}' address='{x.address}'")

Check warning on line 1046 in meshtastic/__main__.py

View check run for this annotation

Codecov / codecov/patch

meshtastic/__main__.py#L1045-L1046

Added lines #L1045 - L1046 were not covered by tests
meshtastic.util.our_exit("BLE scan finished", 0)
elif args.ble:
client = BLEInterface(args.ble_dest, debugOut=logfile, noProto=args.noproto, noNodes=args.no_nodes)
client = BLEInterface(args.ble if args.ble != "any" else None, debugOut=logfile, noProto=args.noproto, noNodes=args.no_nodes)

Check warning on line 1049 in meshtastic/__main__.py

View check run for this annotation

Codecov / codecov/patch

meshtastic/__main__.py#L1049

Added line #L1049 was not covered by tests
elif args.host:
try:
client = meshtastic.tcp_interface.TCPInterface(
Expand Down Expand Up @@ -1114,14 +1114,10 @@ def addConnectionArgs(parser: argparse.ArgumentParser) -> argparse.ArgumentParse

group.add_argument(
"--ble",
help="The BLE device address or name to connect to",
action="store_true",
)

outer.add_argument(
"--ble-dest",
help="The BLE device address or name to connect to",
help="Connect to a BLE device, optionally specifying a device name (defaults to 'any')",
nargs="?",
default=None,
const="any"
)

return parser
Expand Down

0 comments on commit 5c2851d

Please sign in to comment.