Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
58ba725
add the ability to change the target file in the --stay-connected menu
shaggysa Oct 20, 2025
98a6659
fix to open the file properly as a stream as _get_script_path expects
shaggysa Oct 20, 2025
1eb8056
display the current file in the re-compile menu
shaggysa Oct 20, 2025
8e89cfb
close the old file prior to opening a new one
shaggysa Oct 20, 2025
b735de6
send the new file to the hub upon change
shaggysa Oct 21, 2025
ce2447a
add a changelog entry
shaggysa Oct 21, 2025
c2c72fc
implement some suggested changes
shaggysa Oct 23, 2025
92b0d22
replace the bulky if-else block with a match statement
shaggysa Oct 23, 2025
17e0a08
Merge branch 'pybricks:master' into master
shaggysa Oct 23, 2025
e72b050
fix comment alignment
shaggysa Oct 24, 2025
c34ca8d
cli/__init__.py: Add an option to the --stay-connected menu to re-run…
shaggysa Oct 24, 2025
472e002
Merge remote-tracking branch 'origin/master'
shaggysa Oct 24, 2025
802c9d8
cli/__init__.py: fix import layout
shaggysa Oct 24, 2025
87626a9
cli/__init__.py: fix import layout again
shaggysa Oct 24, 2025
d07b2f0
cli/__init__.py: change "Re-run" to "Run" in the new menu option
shaggysa Oct 24, 2025
11b6249
cli/__init__.py: dynamically adjust default response option in --stay…
shaggysa Oct 24, 2025
3a06aad
cli/__init__.py: set required firmware version for running a stored p…
shaggysa Oct 24, 2025
4b1c83d
cli/__init__.py: move default response option setting code out of mat…
shaggysa Oct 24, 2025
f4ca273
cli/__init__.py: always set the default response option to be the one…
shaggysa Oct 25, 2025
72001c4
CHANGELOG.md: add entries for new changes
shaggysa Oct 25, 2025
b42c61c
Update CHANGELOG.md
dlech Oct 25, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]

### Added
- Added the `Run Stored Program` option to the `--stay-connected` menu.
([pybricksdev#125])
- Added the `Change Target File` option to the `--stay-connected` menu.
([pybricksdev#123])

[pybricksdev#123]: https://github.com/pybricks/pybricksdev/pull/123

### Changed
- Changed the default option in the `--stay-connected` menu to be the last
used option. ([pybricksdev#125])

[pybricksdev#125]: https://github.com/pybricks/pybricksdev/pull/125

## [2.1.1] - 2025-09-13

### Fixed
Expand Down
35 changes: 26 additions & 9 deletions pybricksdev/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import argcomplete
import questionary
from argcomplete.completers import FilesCompleter
from packaging.version import Version

from pybricksdev import __name__ as MODULE_NAME
from pybricksdev import __version__ as MODULE_VERSION
Expand Down Expand Up @@ -243,8 +244,9 @@ def is_pybricks_usb(dev):
class ResponseOptions(IntEnum):
RECOMPILE_RUN = 0
RECOMPILE_DOWNLOAD = 1
CHANGE_TARGET_FILE = 2
EXIT = 3
RUN_STORED = 2
CHANGE_TARGET_FILE = 3
EXIT = 4

async def reconnect_hub():
if not await questionary.confirm(
Expand All @@ -271,9 +273,19 @@ async def reconnect_hub():
response_options = [
"Recompile and Run",
"Recompile and Download",
"Run Stored Program",
"Change Target File",
"Exit",
]
# the entry that is selected by default when the menu opens
# this is overridden after the user picks an option
# so that the default option is always the one that was last chosen
default_response_option = (
ResponseOptions.RECOMPILE_RUN
if args.start
else ResponseOptions.RECOMPILE_DOWNLOAD
)

while True:
try:
if args.file is sys.stdin:
Expand All @@ -290,17 +302,13 @@ async def reconnect_hub():
questionary.select(
f"Would you like to re-compile {os.path.basename(args.file.name)}?",
response_options,
default=(
response_options[ResponseOptions.RECOMPILE_RUN]
if args.start
else response_options[
ResponseOptions.RECOMPILE_DOWNLOAD
]
),
default=(response_options[default_response_option]),
).ask_async()
)
)

default_response_option = response_options.index(response)

match response_options.index(response):

case ResponseOptions.RECOMPILE_RUN:
Expand All @@ -311,6 +319,15 @@ async def reconnect_hub():
with _get_script_path(args.file) as script_path:
await hub.download(script_path)

case ResponseOptions.RUN_STORED:
if hub.fw_version < Version("3.2.0-beta.4"):
print(
"Running a stored program remotely is only supported in the hub firmware version >= v3.2.0."
)
else:
await hub.start_user_program()
await hub._wait_for_user_program_stop()

case ResponseOptions.CHANGE_TARGET_FILE:
args.file.close()
while True:
Expand Down