File tree Expand file tree Collapse file tree 1 file changed +15
-9
lines changed Expand file tree Collapse file tree 1 file changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -97,7 +97,7 @@ def add_parser(self, subparsers: argparse._SubParsersAction):
9797 parser .add_argument (
9898 "file" ,
9999 metavar = "<file>" ,
100- help = "path to a MicroPython script or `-` for stdin" ,
100+ help = "path to a MicroPython script, `-` for stdin, or `repl` for interactive prompt " ,
101101 type = str ,
102102 )
103103 parser .add_argument (
@@ -176,15 +176,21 @@ def is_pybricks_usb(dev):
176176 # Connect to the address and run the script
177177 await hub .connect ()
178178 try :
179- if args .file == "-" :
180- with NamedTemporaryFile (suffix = ".py" , delete = False ) as temp :
181- temp .write (sys .stdin .buffer .read ())
182- args .file = temp .name
183-
184- if args .start :
185- await hub .run (args .file , args .wait )
179+ # Handle builtin programs.
180+ if args .file == "repl" :
181+ await hub .run (128 )
186182 else :
187- await hub .download (args .file )
183+ # If using stdin, save to temporary file first.
184+ if args .file == "-" :
185+ with NamedTemporaryFile (suffix = ".py" , delete = False ) as temp :
186+ temp .write (sys .stdin .buffer .read ())
187+ args .file = temp .name
188+
189+ # Download program and optionally start it.
190+ if args .start :
191+ await hub .run (args .file , args .wait )
192+ else :
193+ await hub .download (args .file )
188194 finally :
189195 await hub .disconnect ()
190196
You can’t perform that action at this time.
0 commit comments