From 12f0f74ed136fc2eadafbbcb880f17b9736c2589 Mon Sep 17 00:00:00 2001 From: Pistonight Date: Sun, 8 Mar 2026 14:38:53 -0700 Subject: [PATCH 1/3] bump dependencies --- packages/copper-proc-macros/Cargo.toml | 4 ++-- packages/copper/Cargo.toml | 27 +++++++++++++------------- packages/copper/src/cli/prompt.rs | 8 ++++++++ packages/promethium/Cargo.toml | 6 +++--- 4 files changed, 27 insertions(+), 18 deletions(-) diff --git a/packages/copper-proc-macros/Cargo.toml b/packages/copper-proc-macros/Cargo.toml index 3119d30..e312cba 100644 --- a/packages/copper-proc-macros/Cargo.toml +++ b/packages/copper-proc-macros/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pistonite-cu-proc-macros" -version = "0.2.6" +version = "0.2.7" edition = "2024" description = "Proc-macros for Cu" repository = "https://github.com/Pistonite/cu" @@ -12,7 +12,7 @@ exclude = [ [dependencies.pm] package = "pistonite-pm" -version = "0.2.5" +version = "0.2.6" path = "../promethium" features = ["full"] diff --git a/packages/copper/Cargo.toml b/packages/copper/Cargo.toml index 1ef9615..e1a1770 100644 --- a/packages/copper/Cargo.toml +++ b/packages/copper/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pistonite-cu" -version = "0.7.4" +version = "0.8.0" edition = "2024" description = "Battery-included common utils to speed up development of rust tools" repository = "https://github.com/Pistonite/cu" @@ -11,30 +11,30 @@ exclude = [ ] [dependencies] -pistonite-cu-proc-macros = { version = "0.2.6", path = "../copper-proc-macros" } +pistonite-cu-proc-macros = { version = "0.2.7", path = "../copper-proc-macros" } # --- Always enabled --- -anyhow = "1.0.100" +anyhow = "1.0.102" log = "0.4.29" # --- Command Line Interface --- -oneshot = { version = "0.1.13", optional = true } -env_filter = { version = "0.1.4", optional = true } +oneshot = { version = "0.2.1", optional = true, features = ["std"] } +env_filter = { version = "1.0.0", optional = true } terminal_size = { version = "0.4.3", optional = true } unicode-width = { version = "0.2.2", features = ["cjk"], optional = true } -clap = { version = "4.5.55", features = ["derive"], optional = true } -regex = { version = "1.12.2", optional = true } -ctrlc = { version = "3.5.1", optional = true } +clap = { version = "4.5.60", features = ["derive"], optional = true } +regex = { version = "1.12.3", optional = true } +ctrlc = { version = "3.5.2", optional = true } # --- Coroutine --- num_cpus = { version = "1.17.0", optional = true } -tokio = { version = "1.49.0", optional = true, features = [ +tokio = { version = "1.50.0", optional = true, features = [ "macros", "rt-multi-thread" ] } # --- File System --- dunce = {version="1.0.5", optional = true} -which = {version = "8.0.0", optional = true } +which = {version = "8.0.2", optional = true } pathdiff = {version = "0.2.3", optional=true} filetime = { version = "0.2.27", optional = true} glob = { version = "0.3.3", optional = true } @@ -44,13 +44,13 @@ spin = {version = "0.10.0", optional = true} # for PIO serde = { version = "1.0.228", features = ["derive"], optional = true } serde_json = { version = "1.0.149", optional = true } serde_yaml_ng = { version = "0.10.0", optional = true } -toml = { version = "0.9.11", optional = true } +toml = { version = "1.0.6", optional = true } # derive derive_more = { version = "2.1.1", features = ["full"], optional = true } [target.'cfg(unix)'.dependencies] -libc = "0.2.180" +libc = "0.2.183" [target.'cfg(windows)'.dependencies] windows-sys = { version = "0.61.2", features = ["Win32_Foundation", "Win32_System_Console", "Win32_Storage_FileSystem", "Win32_Security", "Win32_System_SystemServices"] } @@ -58,7 +58,7 @@ windows-sys = { version = "0.61.2", features = ["Win32_Foundation", "Win32_Syste [dev-dependencies] [dev-dependencies.tokio] -version = "1.49.0" +version = "1.50.0" features = [ "macros", "rt-multi-thread", "time" ] [features] @@ -84,6 +84,7 @@ coroutine = [ "dep:tokio", "dep:num_cpus", "tokio/sync", "tokio/io-util", "tokio/io-std", "tokio/time", + "oneshot?/async", ] coroutine-heavy = ["coroutine"] # enable heavy coroutine drived by multi-threaded tokio runtime diff --git a/packages/copper/src/cli/prompt.rs b/packages/copper/src/cli/prompt.rs index 62e4074..483afde 100644 --- a/packages/copper/src/cli/prompt.rs +++ b/packages/copper/src/cli/prompt.rs @@ -440,6 +440,7 @@ impl cu::Result> /// Show the prompt and use the async runtime to wait for input. /// /// If the user presses `Ctrl-C`, `None` will be returned. + #[cfg(feature = "coroutine")] pub async fn co_run(self) -> cu::Result> { check_prompt_level(false)?; co_run_prompt_loop( @@ -480,6 +481,7 @@ impl cu::Result> /// /// If the user presses `Ctrl-C`, the default value set by [`if_cancel`](Self::if_cancel) /// will be returned. + #[cfg(feature = "coroutine")] pub async fn co_run(self) -> cu::Result { check_prompt_level(false)?; // unwrap: safety from builder @@ -523,6 +525,7 @@ impl cu::Result> /// /// If the user presses `Ctrl-C`, an error with message "operation cancelled by user" /// will be returned. + #[cfg(feature = "coroutine")] pub async fn co_run(self) -> cu::Result { check_prompt_level(false)?; match co_run_prompt_loop( @@ -627,6 +630,7 @@ impl cu::Result> /// Show the prompt and use the async runtime to wait for input. /// /// If the user presses `Ctrl-C`, `None` will be returned. + #[cfg(feature = "coroutine")] pub async fn co_run(self) -> cu::Result> { if check_prompt_level(true)? { return Ok(Some(true)); @@ -660,6 +664,7 @@ impl cu::Result> /// /// If the user presses `Ctrl-C`, an error with message "operation cancelled by user" /// will be returned. + #[cfg(feature = "coroutine")] pub async fn co_run(self) -> cu::Result { if check_prompt_level(true)? { return Ok(true); @@ -694,6 +699,7 @@ impl cu::Result> /// /// If the user presses `Ctrl-C`, the default value set by [`if_cancel`](Self::if_cancel) /// will be returned. + #[cfg(feature = "coroutine")] pub async fn co_run(self) -> cu::Result { if check_prompt_level(true)? { return Ok(true); @@ -726,6 +732,7 @@ fn run_yesno_loop(message: String, is_password: bool) -> cu::Result )?); Ok(Some(answer)) } +#[cfg(feature = "coroutine")] async fn co_run_yesno_loop(message: String, is_password: bool) -> cu::Result> { let mut answer = false; let _ = cu::some!( @@ -782,6 +789,7 @@ fn run_prompt_loop cu::Result>( } } #[inline(always)] +#[cfg(feature = "coroutine")] async fn co_run_prompt_loop cu::Result>( message: String, is_password: bool, diff --git a/packages/promethium/Cargo.toml b/packages/promethium/Cargo.toml index 677048c..6870ef0 100644 --- a/packages/promethium/Cargo.toml +++ b/packages/promethium/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pistonite-pm" -version = "0.2.5" +version = "0.2.6" edition = "2024" description = "Procedural Macro Common Utils" repository = "https://github.com/Pistonite/cu" @@ -12,8 +12,8 @@ exclude = [ [dependencies] proc-macro2 = { version = "1.0.106", default-features = false } -quote = { version = "1.0.44", default-features = false } -syn = { version = "2.0.114", default-features = false } +quote = { version = "1.0.45", default-features = false } +syn = { version = "2.0.117", default-features = false } [features] default = [ From a4ffb263e2ac346cfab9e80f8b69aaf605767137 Mon Sep 17 00:00:00 2001 From: Pistonight Date: Sun, 8 Mar 2026 14:40:10 -0700 Subject: [PATCH 2/3] add reset_thread_name --- packages/copper/src/cli/mod.rs | 2 +- packages/copper/src/cli/thread_name.rs | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/copper/src/cli/mod.rs b/packages/copper/src/cli/mod.rs index dfe948d..1b405f1 100644 --- a/packages/copper/src/cli/mod.rs +++ b/packages/copper/src/cli/mod.rs @@ -147,7 +147,7 @@ pub use macros::__print_with_level; mod thread_name; use thread_name::THREAD_NAME; -pub use thread_name::set_thread_name; +pub use thread_name::{reset_thread_name, set_thread_name}; mod printer; mod progress; diff --git a/packages/copper/src/cli/thread_name.rs b/packages/copper/src/cli/thread_name.rs index d74b6af..f6d3da7 100644 --- a/packages/copper/src/cli/thread_name.rs +++ b/packages/copper/src/cli/thread_name.rs @@ -9,3 +9,9 @@ thread_local! { pub fn set_thread_name(name: impl Into) { THREAD_NAME.with_borrow_mut(|x| *x = Some(name.into())) } + +/// Reset the current thread to not show a name +#[inline(always)] +pub fn reset_thread_name() { + THREAD_NAME.with_borrow_mut(|x| *x = None) +} From dafeaded75df043505cef4134aacc33871da1696 Mon Sep 17 00:00:00 2001 From: Pistonight Date: Sun, 8 Mar 2026 14:47:22 -0700 Subject: [PATCH 3/3] make prompt builder must_use --- packages/copper/src/cli/prompt.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/copper/src/cli/prompt.rs b/packages/copper/src/cli/prompt.rs index 483afde..be93cd8 100644 --- a/packages/copper/src/cli/prompt.rs +++ b/packages/copper/src/cli/prompt.rs @@ -149,6 +149,7 @@ type AnswerRecv = oneshot::Receiver>>; /// -: /// ``` #[inline(always)] +#[must_use = "prompt() returns a builder; you must call run() or co_run() to start the prompt"] pub fn prompt( message: impl Into, ) -> PromptBuilder cu::Result> { @@ -174,6 +175,7 @@ pub fn prompt( /// # cu::Ok(()) /// ``` #[inline(always)] +#[must_use = "yesno() returns a builder; you must call run() or co_run() to start the prompt"] pub fn yesno( message: impl Into, ) -> PromptBuilder cu::Result> { @@ -211,6 +213,7 @@ pub struct PromptBuilder< impl PromptBuilder cu::Result> { #[inline(always)] + #[must_use = "you must call run() or co_run() to start the prompt"] fn new(message: impl Into) -> Self { PromptBuilder { message: message.into(), @@ -240,6 +243,7 @@ impl cu::Result Self { self.is_password = true; self @@ -260,6 +264,7 @@ impl cu::Result Self { self.trim_trailing_whitespace = trim; self @@ -308,6 +313,7 @@ impl cu::Result(self, validator: F) -> PromptBuilder where F: FnMut(&mut String) -> cu::Result, @@ -344,6 +350,7 @@ impl cu::Result> /// # Ok(()) } /// ``` #[inline(always)] + #[must_use = "you must call run() or co_run() to start the prompt"] pub fn yesno(mut self) -> PromptBuilder { self.message.push_str(" [y/n]"); PromptBuilder { @@ -378,6 +385,7 @@ impl cu::Result> /// `Option` - Just that the prompt creator has control over /// the outcome of the prompt, rather than the prompt consumer accessing the outcome. #[inline(always)] + #[must_use = "you must call run() or co_run() to start the prompt"] pub fn if_cancel( self, default: impl Into, @@ -407,6 +415,7 @@ impl cu::Result> /// # Ok(()) } /// ``` #[inline(always)] + #[must_use = "you must call run() or co_run() to start the prompt"] pub fn or_cancel(mut self) -> PromptBuilder { self.message.push_str(" (Ctrl-C to cancel)"); PromptBuilder { @@ -568,6 +577,7 @@ impl cu::Result> /// `Option` - Just that the prompt creator has control over /// the outcome of the prompt, rather than the prompt consumer accessing the outcome. #[inline(always)] + #[must_use = "you must call run() or co_run() to start the prompt"] pub fn if_cancel(self, default: bool) -> PromptBuilder { PromptBuilder { message: self.message, @@ -600,6 +610,7 @@ impl cu::Result> /// # } /// ``` #[inline(always)] + #[must_use = "you must call run() or co_run() to start the prompt"] pub fn or_cancel(mut self) -> PromptBuilder { self.message.push_str(" (Ctrl-C to cancel)"); PromptBuilder {