@@ -197,20 +197,37 @@ impl Scope {
197197 Self ( scope)
198198 }
199199
200+ /// Validates argument inputs and creates a Tauri sidecar [`Command`].
201+ #[ cfg( shell_sidecar) ]
202+ pub fn prepare_sidecar (
203+ & self ,
204+ command_name : & str ,
205+ command_script : & str ,
206+ args : ExecuteArgs ,
207+ ) -> Result < Command , ScopeError > {
208+ self . _prepare ( command_name, args, Some ( command_script) )
209+ }
210+
211+ /// Validates argument inputs and creates a Tauri [`Command`].
212+ #[ cfg( shell_execute) ]
213+ pub fn prepare ( & self , command_name : & str , args : ExecuteArgs ) -> Result < Command , ScopeError > {
214+ self . _prepare ( command_name, args, None )
215+ }
216+
200217 /// Validates argument inputs and creates a Tauri [`Command`].
201218 #[ cfg( any( shell_execute, shell_sidecar) ) ]
202- pub fn prepare (
219+ pub fn _prepare (
203220 & self ,
204221 command_name : & str ,
205222 args : ExecuteArgs ,
206- sidecar : bool ,
223+ sidecar : Option < & str > ,
207224 ) -> Result < Command , ScopeError > {
208225 let command = match self . 0 . scopes . get ( command_name) {
209226 Some ( command) => command,
210227 None => return Err ( ScopeError :: NotFound ( command_name. into ( ) ) ) ,
211228 } ;
212229
213- if command. sidecar != sidecar {
230+ if command. sidecar != sidecar. is_some ( ) {
214231 return Err ( ScopeError :: BadSidecarFlag ) ;
215232 }
216233
@@ -250,7 +267,17 @@ impl Scope {
250267 ( Some ( _) , _) => Err ( ScopeError :: InvalidInput ( command_name. into ( ) ) ) ,
251268 } ?;
252269
253- let command_s = command. command . to_string_lossy ( ) ;
270+ let command_s = sidecar
271+ . map ( |s| {
272+ std:: path:: PathBuf :: from ( s)
273+ . components ( )
274+ . last ( )
275+ . unwrap ( )
276+ . as_os_str ( )
277+ . to_string_lossy ( )
278+ . into_owned ( )
279+ } )
280+ . unwrap_or_else ( || command. command . to_string_lossy ( ) . into_owned ( ) ) ;
254281 let command = if command. sidecar {
255282 Command :: new_sidecar ( command_s) . map_err ( ScopeError :: Sidecar ) ?
256283 } else {
0 commit comments