@@ -523,7 +523,7 @@ fn print_lockfile_generation(
523
523
if let Some ( note) = note {
524
524
assert_eq ! ( change. kind, PackageChangeKind :: Added ) ;
525
525
ws. gctx ( ) . shell ( ) . status_with_color (
526
- "Adding" ,
526
+ change . kind . status ( ) ,
527
527
format ! ( "{package_id}{note}" ) ,
528
528
& style:: NOTE ,
529
529
) ?;
@@ -579,11 +579,11 @@ fn print_lockfile_sync(
579
579
if change. kind == PackageChangeKind :: Downgraded {
580
580
ws. gctx ( )
581
581
. shell ( )
582
- . status_with_color ( "Downgrading" , msg, & style:: WARN ) ?;
582
+ . status_with_color ( change . kind . status ( ) , msg, & style:: WARN ) ?;
583
583
} else {
584
584
ws. gctx ( )
585
585
. shell ( )
586
- . status_with_color ( "Updating" , msg, & style:: GOOD ) ?;
586
+ . status_with_color ( change . kind . status ( ) , msg, & style:: GOOD ) ?;
587
587
}
588
588
} else {
589
589
if change. kind == PackageChangeKind :: Added {
@@ -592,7 +592,7 @@ fn print_lockfile_sync(
592
592
let note = required_rust_version. or ( latest) . unwrap_or_default ( ) ;
593
593
594
594
ws. gctx ( ) . shell ( ) . status_with_color (
595
- "Adding" ,
595
+ change . kind . status ( ) ,
596
596
format ! ( "{package_id}{note}" ) ,
597
597
& style:: NOTE ,
598
598
) ?;
@@ -649,16 +649,16 @@ fn print_lockfile_updates(
649
649
if change. kind == PackageChangeKind :: Downgraded {
650
650
ws. gctx ( )
651
651
. shell ( )
652
- . status_with_color ( "Downgrading" , msg, & style:: WARN ) ?;
652
+ . status_with_color ( change . kind . status ( ) , msg, & style:: WARN ) ?;
653
653
} else {
654
654
ws. gctx ( )
655
655
. shell ( )
656
- . status_with_color ( "Updating" , msg, & style:: GOOD ) ?;
656
+ . status_with_color ( change . kind . status ( ) , msg, & style:: GOOD ) ?;
657
657
}
658
658
} else {
659
659
if change. kind == PackageChangeKind :: Removed {
660
660
ws. gctx ( ) . shell ( ) . status_with_color (
661
- "Removing" ,
661
+ change . kind . status ( ) ,
662
662
format ! ( "{package_id}" ) ,
663
663
& style:: ERROR ,
664
664
) ?;
@@ -668,7 +668,7 @@ fn print_lockfile_updates(
668
668
let note = required_rust_version. or ( latest) . unwrap_or_default ( ) ;
669
669
670
670
ws. gctx ( ) . shell ( ) . status_with_color (
671
- "Adding" ,
671
+ change . kind . status ( ) ,
672
672
format ! ( "{package_id}{note}" ) ,
673
673
& style:: NOTE ,
674
674
) ?;
@@ -685,7 +685,7 @@ fn print_lockfile_updates(
685
685
}
686
686
if ws. gctx ( ) . shell ( ) . verbosity ( ) == Verbosity :: Verbose {
687
687
ws. gctx ( ) . shell ( ) . status_with_color (
688
- "Unchanged" ,
688
+ change . kind . status ( ) ,
689
689
format ! ( "{package_id}{note}" ) ,
690
690
& anstyle:: Style :: new ( ) . bold ( ) ,
691
691
) ?;
@@ -919,6 +919,16 @@ impl PackageChangeKind {
919
919
Self :: Removed | Self :: Unchanged => false ,
920
920
}
921
921
}
922
+
923
+ pub fn status ( & self ) -> & ' static str {
924
+ match self {
925
+ Self :: Added => "Adding" ,
926
+ Self :: Removed => "Removing" ,
927
+ Self :: Upgraded => "Updating" ,
928
+ Self :: Downgraded => "Downgrading" ,
929
+ Self :: Unchanged => "Unchanged" ,
930
+ }
931
+ }
922
932
}
923
933
924
934
/// All resolved versions of a package name within a [`SourceId`]
0 commit comments