@@ -375,36 +375,11 @@ where
375
375
Ok ( utils:: ExitCode ( 0 ) )
376
376
}
377
377
378
- pub ( crate ) fn list_targets ( distributable : DistributableToolchain < ' _ > ) -> Result < utils:: ExitCode > {
379
- let mut t = process ( ) . stdout ( ) . terminal ( ) ;
380
- let manifestation = distributable. get_manifestation ( ) ?;
381
- let config = manifestation. read_config ( ) ?. unwrap_or_default ( ) ;
382
- let manifest = distributable. get_manifest ( ) ?;
383
- let components = manifest. query_components ( distributable. desc ( ) , & config) ?;
384
- for component in components {
385
- if component. component . short_name_in_manifest ( ) == "rust-std" {
386
- let target = component
387
- . component
388
- . target
389
- . as_ref ( )
390
- . expect ( "rust-std should have a target" ) ;
391
- if component. installed {
392
- let _ = t. attr ( terminalsource:: Attr :: Bold ) ;
393
- let _ = writeln ! ( t. lock( ) , "{target} (installed)" ) ;
394
- let _ = t. reset ( ) ;
395
- } else if component. available {
396
- let _ = writeln ! ( t. lock( ) , "{target}" ) ;
397
- }
398
- }
399
- }
400
-
401
- Ok ( utils:: ExitCode ( 0 ) )
402
- }
403
-
404
- pub ( crate ) fn list_installed_targets (
378
+ pub ( crate ) fn list_targets (
405
379
distributable : DistributableToolchain < ' _ > ,
380
+ installed_only : bool ,
406
381
) -> Result < utils:: ExitCode > {
407
- let t = process ( ) . stdout ( ) ;
382
+ let mut t = process ( ) . stdout ( ) . terminal ( ) ;
408
383
let manifestation = distributable. get_manifestation ( ) ?;
409
384
let config = manifestation. read_config ( ) ?. unwrap_or_default ( ) ;
410
385
let manifest = distributable. get_manifest ( ) ?;
@@ -416,11 +391,20 @@ pub(crate) fn list_installed_targets(
416
391
. target
417
392
. as_ref ( )
418
393
. expect ( "rust-std should have a target" ) ;
419
- if component. installed {
420
- writeln ! ( t. lock( ) , "{target}" ) ?;
394
+ match ( component. available , component. installed , installed_only) {
395
+ ( false , _, _) | ( _, false , true ) => continue ,
396
+ ( true , true , false ) => {
397
+ t. attr ( terminalsource:: Attr :: Bold ) ?;
398
+ writeln ! ( t. lock( ) , "{target} (installed)" ) ?;
399
+ t. reset ( ) ?;
400
+ }
401
+ ( true , _, false ) | ( _, true , true ) => {
402
+ writeln ! ( t. lock( ) , "{target}" ) ?;
403
+ }
421
404
}
422
405
}
423
406
}
407
+
424
408
Ok ( utils:: ExitCode ( 0 ) )
425
409
}
426
410
0 commit comments