Skip to content

Commit

Permalink
chore: 优化控制台打印时的字体样式
Browse files Browse the repository at this point in the history
  • Loading branch information
Cnotech committed Jul 23, 2024
1 parent b10a868 commit c6a0816
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/entrances/mirror.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub fn mirror_add(url: &String, should_match_name: Option<String>) -> Result<Str
} else {
url.to_string()
};
log!("Info:Hand shaking with '{url}'...");
log!("Debug:Hand shaking with '{url}'...");

// 请求 url
let res: MirrorHello = get(&url)
Expand Down Expand Up @@ -64,7 +64,7 @@ pub fn mirror_add(url: &String, should_match_name: Option<String>) -> Result<Str

// 请求软件包列表
let (ps_url, _) = filter_service_from_meta(res, ServiceKeys::PkgSoftware)?;
log!("Info:Fetching software list from '{ps_url}'...");
log!("Debug:Fetching software list from '{ps_url}'...");
let pkg_software_res: MirrorPkgSoftware = get(&ps_url)
.map_err(|e| anyhow!("Error:Failed to fetch '{ps_url}' : {e}"))?
.json()
Expand Down
15 changes: 11 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ fn router(action: Action) -> Result<String> {
.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())
Expand All @@ -122,9 +122,16 @@ fn router(action: Action) -> Result<String> {
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
)
});
Expand Down

0 comments on commit c6a0816

Please sign in to comment.