5454@click .option ("--environment" , "-e" , metavar = "<environment>" )
5555@click .option ("--load-mode" , type = ProjectOptions ["env.debug_load_mode" ].type )
5656@click .option ("--verbose" , "-v" , is_flag = True )
57- @click .option ("--interface" , type = click .Choice (["gdb" ]), default = "gdb" )
58- @click .argument ("__unprocessed " , nargs = - 1 , type = click .UNPROCESSED )
57+ @click .option ("--interface" , type = click .Choice (["gdb" ]))
58+ @click .argument ("client_extra_args " , nargs = - 1 , type = click .UNPROCESSED )
5959@click .pass_context
6060def cli (
6161 ctx ,
@@ -65,10 +65,13 @@ def cli(
6565 load_mode ,
6666 verbose ,
6767 interface ,
68- __unprocessed ,
68+ client_extra_args ,
6969):
7070 app .set_session_var ("custom_project_conf" , project_conf )
7171
72+ if not interface and client_extra_args :
73+ raise click .UsageError ("Please specify debugging interface" )
74+
7275 # use env variables from Eclipse or CLion
7376 for name in ("CWD" , "PWD" , "PLATFORMIO_PROJECT_DIR" ):
7477 if is_platformio_project (project_dir ):
@@ -92,7 +95,7 @@ def cli(
9295 env_name ,
9396 load_mode ,
9497 verbose ,
95- __unprocessed ,
98+ client_extra_args ,
9699 )
97100 if helpers .is_gdbmi_mode ():
98101 os .environ ["PLATFORMIO_DISABLE_PROGRESSBAR" ] = "true"
@@ -103,19 +106,19 @@ def cli(
103106 else :
104107 debug_config = _configure (* configure_args )
105108
106- _run (project_dir , debug_config , __unprocessed )
109+ _run (project_dir , debug_config , client_extra_args )
107110
108111 return None
109112
110113
111- def _configure (ctx , project_config , env_name , load_mode , verbose , __unprocessed ):
114+ def _configure (ctx , project_config , env_name , load_mode , verbose , client_extra_args ):
112115 platform = PlatformFactory .from_env (env_name , autoinstall = True )
113116 debug_config = DebugConfigFactory .new (
114117 platform ,
115118 project_config ,
116119 env_name ,
117120 )
118- if "--version" in __unprocessed :
121+ if "--version" in client_extra_args :
119122 raise ReturnErrorCode (
120123 subprocess .run (
121124 [debug_config .client_executable_path , "--version" ], check = True
@@ -161,12 +164,12 @@ def _configure(ctx, project_config, env_name, load_mode, verbose, __unprocessed)
161164 return debug_config
162165
163166
164- def _run (project_dir , debug_config , __unprocessed ):
167+ def _run (project_dir , debug_config , client_extra_args ):
165168 loop = asyncio .ProactorEventLoop () if IS_WINDOWS else asyncio .get_event_loop ()
166169 asyncio .set_event_loop (loop )
167170
168171 client = GDBClientProcess (project_dir , debug_config )
169- coro = client .run (__unprocessed )
172+ coro = client .run (client_extra_args )
170173 try :
171174 signal .signal (signal .SIGINT , signal .SIG_IGN )
172175 loop .run_until_complete (coro )
0 commit comments