aboutsummaryrefslogtreecommitdiff
path: root/dev_tools/src/lib.rs
diff options
context:
space:
mode:
authorWeicao-CatilGrass <1992414357@qq.com>2026-06-11 22:42:25 +0800
committerWeicao-CatilGrass <1992414357@qq.com>2026-06-11 22:42:25 +0800
commit56dddebe515a1017d94b3dfc8c7413e8c275cecb (patch)
tree8815d1901e8e587b2a0b70d356f50031c7628012 /dev_tools/src/lib.rs
parentc0dbb769b53010944e42e04b554d996f302f412b (diff)
Add `.temp` directory to ignored paths in CI build
Diffstat (limited to 'dev_tools/src/lib.rs')
-rw-r--r--dev_tools/src/lib.rs43
1 files changed, 43 insertions, 0 deletions
diff --git a/dev_tools/src/lib.rs b/dev_tools/src/lib.rs
index ce897df..13ed71f 100644
--- a/dev_tools/src/lib.rs
+++ b/dev_tools/src/lib.rs
@@ -44,6 +44,16 @@ macro_rules! eprintln_cargo_style {
};
}
+#[macro_export]
+macro_rules! wprintln_cargo_style {
+ ($fmt:literal, $($arg:tt)*) => {
+ $crate::wprintln_cargo_style(format!($fmt, $($arg)*))
+ };
+ ($cmd:expr) => {
+ $crate::wprintln_cargo_style($cmd)
+ };
+}
+
/// Print a message in cargo style format, with bold green prefix.
///
/// # Panics
@@ -81,6 +91,39 @@ pub fn eprintln_cargo_style(str: impl Into<String>) {
println!("{}: {}", "error".bold().bright_red(), str.into());
}
+/// Print a message in cargo style format, with bold yellow prefix (warning style).
+///
+/// # Panics
+///
+/// Panics if the prefix (text before the first `:`) exceeds 12 characters.
+pub fn wprintln_cargo_style(str: impl Into<String>) {
+ let s = str.into();
+ let (prefix, content) = if let Some(pos) = s.find(':') {
+ (
+ s[..pos].trim().to_string(),
+ s[pos + 1..].trim_start().to_string(),
+ )
+ } else {
+ (String::new(), s.trim().to_string())
+ };
+
+ assert!(
+ prefix.len() <= 12,
+ "prefix length exceeds 12: '{}' has length {}",
+ prefix,
+ prefix.len()
+ );
+
+ let padding = " ".repeat(12 - prefix.len());
+
+ println!(
+ "{}{} {}",
+ padding,
+ prefix.bold().bright_yellow(),
+ content.trim()
+ );
+}
+
/// Run a shell command and return its exit status.
///
/// # Panics