From 60d55f047a6bd4014d3dbf445f0d669251c4cd91 Mon Sep 17 00:00:00 2001 From: saying Date: Sat, 19 Jul 2025 12:30:06 +0800 Subject: [PATCH] feat(xtask): show rust env --- Cargo.lock | 1 + Cargo.toml | 3 ++- crates/xtask/Cargo.toml | 1 + crates/xtask/src/lib.rs | 18 ++++++++++++++++++ crates/xtask/src/main.rs | 2 ++ 5 files changed, 24 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index bc097a2..27d2557 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3653,6 +3653,7 @@ dependencies = [ "anyhow", "clap", "duct", + "owo-colors", "which", ] diff --git a/Cargo.toml b/Cargo.toml index 3efffeb..ae5c81e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,8 @@ panic = "abort" [workspace.dependencies] -positioned-io = { version = "0.3.3", default-features = false } +owo-colors = "4.2" +positioned-io = { version = "0.3", default-features = false } pretty_assertions = "1" rand = "0.9" plist = "1" diff --git a/crates/xtask/Cargo.toml b/crates/xtask/Cargo.toml index f24b86d..58cafec 100644 --- a/crates/xtask/Cargo.toml +++ b/crates/xtask/Cargo.toml @@ -16,6 +16,7 @@ anyhow = { workspace = true } clap = { workspace = true, features = ["derive"] } duct = { workspace = true } which = { workspace = true } +owo-colors = { workspace = true } [lints] workspace = true diff --git a/crates/xtask/src/lib.rs b/crates/xtask/src/lib.rs index 1abae91..5f79eef 100644 --- a/crates/xtask/src/lib.rs +++ b/crates/xtask/src/lib.rs @@ -6,9 +6,27 @@ use std::{convert::Into, ffi::OsString}; use anyhow::Result; +use owo_colors::OwoColorize; pub mod args; +pub fn show_rust_env() -> Result<()> { + split_line(); + duct::cmd!("rustup", "show").run()?; + split_line(); + let tools = ["rustc", "cargo", "rustfmt"]; + for ele in tools { + duct::cmd!(ele, "-v", "-V").run()?; + split_line(); + } + Ok(()) +} + +fn split_line() { + let var = "=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>"; + println!("{}", var.yellow()); +} + /// --lib --bins pub fn check_lb() -> Result<()> { duct::cmd!( diff --git a/crates/xtask/src/main.rs b/crates/xtask/src/main.rs index 8aa8d0d..73af050 100644 --- a/crates/xtask/src/main.rs +++ b/crates/xtask/src/main.rs @@ -2,6 +2,8 @@ use clap::Parser; use xtask::args::{self, Task}; fn main() -> anyhow::Result<()> { + xtask::show_rust_env()?; + let args = args::Args::parse(); match args.task { Task::Check => {