@@ -10,6 +10,9 @@ use std::path::Path;
10
10
11
11
use cargo_util:: paths;
12
12
use indexmap:: IndexSet ;
13
+ use termcolor:: Color :: Green ;
14
+ use termcolor:: Color :: Red ;
15
+ use termcolor:: ColorSpec ;
13
16
use toml_edit:: Item as TomlItem ;
14
17
15
18
use crate :: core:: dependency:: DepKind ;
@@ -544,6 +547,10 @@ fn populate_available_features(
544
547
fn print_msg ( shell : & mut Shell , dep : & Dependency , section : & [ String ] ) -> CargoResult < ( ) > {
545
548
use std:: fmt:: Write ;
546
549
550
+ if matches ! ( shell. verbosity( ) , crate :: core:: shell:: Verbosity :: Quiet ) {
551
+ return Ok ( ( ) ) ;
552
+ }
553
+
547
554
let mut message = String :: new ( ) ;
548
555
write ! ( message, "{}" , dep. name) ?;
549
556
match dep. source ( ) {
@@ -573,6 +580,7 @@ fn print_msg(shell: &mut Shell, dep: &Dependency, section: &[String]) -> CargoRe
573
580
} ;
574
581
write ! ( message, " {section}" ) ?;
575
582
write ! ( message, "." ) ?;
583
+ shell. status ( "Adding" , message) ?;
576
584
577
585
let mut activated: IndexSet < _ > = dep. features . iter ( ) . flatten ( ) . map ( |s| s. as_str ( ) ) . collect ( ) ;
578
586
if dep. default_features ( ) . unwrap_or ( true ) {
@@ -604,20 +612,20 @@ fn print_msg(shell: &mut Shell, dep: &Dependency, section: &[String]) -> CargoRe
604
612
. collect :: < Vec < _ > > ( ) ;
605
613
deactivated. sort ( ) ;
606
614
if !activated. is_empty ( ) || !deactivated. is_empty ( ) {
607
- writeln ! ( message ) ? ;
608
- write ! ( message , "{:>13 }Features:", " " ) ?;
615
+ let prefix = format ! ( "{:>13}" , " " ) ;
616
+ shell . write_stderr ( format_args ! ( "{ }Features:\n ", prefix ) , & ColorSpec :: new ( ) ) ?;
609
617
for feat in activated {
610
- writeln ! ( message) ?;
611
- write ! ( message, "{:>13}+ {}" , " " , feat) ?;
618
+ shell. write_stderr ( & prefix, & ColorSpec :: new ( ) ) ?;
619
+ shell. write_stderr ( '+' , & ColorSpec :: new ( ) . set_bold ( true ) . set_fg ( Some ( Green ) ) ) ?;
620
+ shell. write_stderr ( format_args ! ( " {}\n " , feat) , & ColorSpec :: new ( ) ) ?;
612
621
}
613
622
for feat in deactivated {
614
- writeln ! ( message) ?;
615
- write ! ( message, "{:>13}- {}" , " " , feat) ?;
623
+ shell. write_stderr ( & prefix, & ColorSpec :: new ( ) ) ?;
624
+ shell. write_stderr ( '-' , & ColorSpec :: new ( ) . set_bold ( true ) . set_fg ( Some ( Red ) ) ) ?;
625
+ shell. write_stderr ( format_args ! ( " {}\n " , feat) , & ColorSpec :: new ( ) ) ?;
616
626
}
617
627
}
618
628
619
- shell. status ( "Adding" , message) ?;
620
-
621
629
Ok ( ( ) )
622
630
}
623
631
0 commit comments