From c6a08166e89612975e8fc22a163805a83e4a1e21 Mon Sep 17 00:00:00 2001 From: Cno Date: Tue, 23 Jul 2024 23:16:01 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E4=BC=98=E5=8C=96=E6=8E=A7=E5=88=B6?= =?UTF-8?q?=E5=8F=B0=E6=89=93=E5=8D=B0=E6=97=B6=E7=9A=84=E5=AD=97=E4=BD=93?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/entrances/mirror.rs | 4 ++-- src/main.rs | 15 +++++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/entrances/mirror.rs b/src/entrances/mirror.rs index cd33a216..385d5dba 100644 --- a/src/entrances/mirror.rs +++ b/src/entrances/mirror.rs @@ -34,7 +34,7 @@ pub fn mirror_add(url: &String, should_match_name: Option) -> Result) -> Result Result { .fold(format!("\nFound {len} results:\n"), |acc, node| { acc + &format!( " {scope}/{name} ({version}) {mirror}\n", - name = node.name, + name = node.name.cyan().bold(), version = node.version, - scope = node.scope, + scope = node.scope.cyan().italic(), mirror = node .from_mirror .unwrap_or("".to_string()) @@ -122,9 +122,16 @@ fn router(action: Action) -> Result { let res: String = list.into_iter() .fold(String::from("\nInstalled packages:\n"), |acc, node| { + let update_tip = if let Some(online_diff) = node.online { + format!(" ↑ {ver} ", ver = online_diff.version) + .green() + .to_string() + } else { + String::new() + }; acc + &format!( - " {name} {version}\n", - name = node.name, + " {name} {version}{update_tip}\n", + name = node.name.cyan().bold(), version = node.local.unwrap().version ) });