6262 show_default = True ,
6363 help = """Show progress""" ,
6464)
65- def cli_list_mcus (serial : List [str ], ignore : List [str ], bluetooth : bool , as_json : bool , progress : bool = True ) -> int :
65+ @click .option (
66+ "--reset/--no-reset" ,
67+ "reset" ,
68+ is_flag = True ,
69+ default = True ,
70+ show_default = True ,
71+ help = """Reset the board after listing.""" ,
72+ )
73+ def cli_list_mcus (serial : List [str ], ignore : List [str ], bluetooth : bool , as_json : bool , progress : bool = True , reset : bool = True ) -> int :
6674 """List the connected MCU boards, and output in a nice table or json."""
6775 from .connected import list_mcus
6876 from .list import show_mcus
@@ -82,13 +90,14 @@ def cli_list_mcus(serial: List[str], ignore: List[str], bluetooth: bool, as_json
8290
8391 if progress :
8492 show_mcus (conn_mcus , refresh = False )
85- for mcu in conn_mcus :
86- # reset the board so it can continue to whatever it was running before
87- if mcu .family == "circuitpython" :
88- # CircuitPython boards need a special reset command
89- mcu .run_command (["exec" , "--no-follow" , "import microcontroller,time;time.sleep(0.01);microcontroller.reset()" ], resume = False )
90- elif mcu .family == "unknown" :
91- continue
92- else :
93- mcu .run_command ("reset" )
93+ if reset :
94+ for mcu in conn_mcus :
95+ # reset the board so it can continue to whatever it was running before
96+ if mcu .family == "circuitpython" :
97+ # CircuitPython boards need a special reset command
98+ mcu .run_command (["exec" , "--no-follow" , "import microcontroller,time;time.sleep(0.01);microcontroller.reset()" ], resume = False )
99+ elif mcu .family == "unknown" :
100+ continue
101+ else :
102+ mcu .run_command ("reset" )
94103 return 0 if conn_mcus else 1
0 commit comments