File tree 2 files changed +25
-1
lines changed 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,13 @@ impl Subcommand {
34
34
_ => false ,
35
35
}
36
36
}
37
+
38
+ pub fn needs_target_in_command ( self ) -> bool {
39
+ match self {
40
+ Subcommand :: Metadata => false ,
41
+ _ => true ,
42
+ }
43
+ }
37
44
}
38
45
39
46
impl < ' a > From < & ' a str > for Subcommand {
Original file line number Diff line number Diff line change @@ -278,6 +278,23 @@ fn run() -> Result<ExitStatus> {
278
278
false
279
279
} ,
280
280
} ;
281
+
282
+ let filtered_args = if args. subcommand . map_or ( false , |s| !s. needs_target_in_command ( ) ) {
283
+ let mut filtered_args = Vec :: new ( ) ;
284
+ let mut args_iter = args. all . clone ( ) . into_iter ( ) ;
285
+ while let Some ( arg) = args_iter. next ( ) {
286
+ if arg == "--target" {
287
+ args_iter. next ( ) ;
288
+ } else if arg. starts_with ( "--target=" ) {
289
+ // NOOP
290
+ } else {
291
+ filtered_args. push ( arg)
292
+ }
293
+ }
294
+ filtered_args
295
+ } else {
296
+ args. all . clone ( )
297
+ } ;
281
298
282
299
if image_exists && target. needs_docker ( ) &&
283
300
args. subcommand . map ( |sc| sc. needs_docker ( ) ) . unwrap_or ( false ) {
@@ -289,7 +306,7 @@ fn run() -> Result<ExitStatus> {
289
306
}
290
307
291
308
return docker:: run ( & target,
292
- & args . all ,
309
+ & filtered_args ,
293
310
& args. target_dir ,
294
311
& root,
295
312
toml. as_ref ( ) ,
You can’t perform that action at this time.
0 commit comments