Skip to content

Commit dc0e7a4

Browse files
committed
cle: change run command --wait option
This changes the wait option to use the more typical --wait/--no-wait pattern instead of having to supply a boolean string value.
1 parent bdb9163 commit dc0e7a4

File tree

2 files changed

+26
-10
lines changed

2 files changed

+26
-10
lines changed

CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
- Support for Python 3.9.
1111

1212
### Changed
13-
- Update to Bleak v0.12.0
13+
- Update to Bleak v0.12.0.
14+
- Change `pybricksdev run` to use `--wait`/`--no-wait` instead of `--wait=False`.
1415

1516
### Fixed
16-
- Fix `pybricks lwp3 repl` can only connect to remote control.
17+
- Fix `pybricksdev lwp3 repl` can only connect to remote control.
1718
- Fix Technic Large hub Bluetooth hub kind.
1819

1920
## [1.0.0-alpha.9] - 2021-05-27

pybricksdev/cli/__init__.py

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,28 @@ def add_parser(self, subparsers: argparse._SubParsersAction):
109109
"Bluetooth device name or Bluetooth address for BLE connection; "
110110
"serial port name for USB connection",
111111
)
112-
parser.add_argument(
113-
"--wait",
114-
help="Await program completion (True) or disconnect immediately (False)",
115-
required=False,
116-
default="True",
117-
choices=["True", "False"],
118-
)
112+
113+
if hasattr(argparse, "BooleanOptionalAction"):
114+
# BooleanOptionalAction requires Python 3.9
115+
parser.add_argument(
116+
"--wait",
117+
help="wait for the program to complete before disconnecting",
118+
action=argparse.BooleanOptionalAction,
119+
default=True,
120+
)
121+
else:
122+
parser.add_argument(
123+
"--wait",
124+
help="wait for the program to complete before disconnecting (default)",
125+
action="store_true",
126+
default=True,
127+
)
128+
parser.add_argument(
129+
"--no-wait",
130+
help="disconnect as soon as program is done downloading",
131+
action="store_false",
132+
dest="wait",
133+
)
119134

120135
async def run(self, args: argparse.Namespace):
121136
from ..ble import find_device
@@ -165,7 +180,7 @@ async def run(self, args: argparse.Namespace):
165180
# Connect to the address and run the script
166181
await hub.connect(device_or_address)
167182
try:
168-
await hub.run(script_path, args.wait == "True")
183+
await hub.run(script_path, args.wait)
169184
finally:
170185
await hub.disconnect()
171186

0 commit comments

Comments
 (0)