diff --git a/Cargo.lock b/Cargo.lock index fddb56f..8113b88 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -250,12 +250,6 @@ version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" -[[package]] -name = "hermit-abi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" - [[package]] name = "ignore" version = "0.4.23" @@ -299,17 +293,6 @@ dependencies = [ "unicode-width", ] -[[package]] -name = "io-lifetimes" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" -dependencies = [ - "hermit-abi", - "libc", - "windows-sys 0.48.0", -] - [[package]] name = "itertools" version = "0.11.0" @@ -355,12 +338,6 @@ dependencies = [ "vcpkg", ] -[[package]] -name = "linux-raw-sys" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" - [[package]] name = "linux-raw-sys" version = "0.4.14" @@ -489,6 +466,7 @@ dependencies = [ "serde", "serde_json", "sys-locale", + "terminal_size", "textwrap", ] @@ -664,20 +642,6 @@ dependencies = [ "triomphe", ] -[[package]] -name = "rustix" -version = "0.37.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fea8ca367a3a01fe35e6943c400addf443c0f57670e6ec51196f71a4b8762dd2" -dependencies = [ - "bitflags 1.3.2", - "errno", - "io-lifetimes", - "libc", - "linux-raw-sys 0.3.8", - "windows-sys 0.48.0", -] - [[package]] name = "rustix" version = "0.38.42" @@ -687,7 +651,7 @@ dependencies = [ "bitflags 2.6.0", "errno", "libc", - "linux-raw-sys 0.4.14", + "linux-raw-sys", "windows-sys 0.59.0", ] @@ -889,18 +853,18 @@ dependencies = [ "cfg-if", "fastrand", "once_cell", - "rustix 0.38.42", + "rustix", "windows-sys 0.59.0", ] [[package]] name = "terminal_size" -version = "0.2.6" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e6bf6f19e9f8ed8d4048dc22981458ebcf406d67e94cd422e5ecd73d63b3237" +checksum = "5352447f921fda68cf61b4101566c0bdb5104eff6804d0678e5227580ab6a4e9" dependencies = [ - "rustix 0.37.27", - "windows-sys 0.48.0", + "rustix", + "windows-sys 0.59.0", ] [[package]] @@ -910,7 +874,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23d434d3f8967a09480fb04132ebe0a3e088c173e6d0ee7897abbdf4eab0f8b9" dependencies = [ "smawk", - "terminal_size", "unicode-linebreak", "unicode-width", ] diff --git a/core/src/shell.rs b/core/src/shell.rs index 6932fb5..79c71f2 100644 --- a/core/src/shell.rs +++ b/core/src/shell.rs @@ -312,6 +312,7 @@ pub fn module_output(data: &Data, module: &str) -> Option> { .env("_PR_LAST_COMMAND", last_command) .env("_PR_ERROR_MSG", error_msg) .env("_PR_EXECUTABLES", executables) + .stderr(std::process::Stdio::inherit()) .output() .expect("failed to execute process"); diff --git a/module-request-ai/Cargo.toml b/module-request-ai/Cargo.toml index 5e5a6fa..f8166db 100644 --- a/module-request-ai/Cargo.toml +++ b/module-request-ai/Cargo.toml @@ -15,7 +15,8 @@ sys-locale = "0.3" rust-i18n = "3" serde_json = { version = "1.0" } serde = { version = "1.0", features = ["derive"]} -textwrap = { version = "0.16", features = ["terminal_size"] } +textwrap = "0.16" +terminal_size = "0.4" curl = { version = "0.4", optional = true } diff --git a/module-request-ai/src/main.rs b/module-request-ai/src/main.rs index 0bbc51c..1a921ab 100644 --- a/module-request-ai/src/main.rs +++ b/module-request-ai/src/main.rs @@ -1,6 +1,6 @@ use crate::requests::ai_suggestion; use colored::Colorize; -use textwrap::{fill, termwidth}; +use textwrap::fill; mod requests; #[macro_use] @@ -28,9 +28,19 @@ fn main() -> Result<(), std::io::Error> { let warn = format!("{}:", t!("ai-suggestion")).bold().blue(); let note = fill(&suggest.note, termwidth()); - eprintln!("{}\n{}", warn, note); + eprintln!("{}\n{}\n", warn, note); let command = suggest.command; print!("{}<_PR_BR>", command); } Ok(()) } + +fn termwidth() -> usize { + use terminal_size::{terminal_size, Height, Width}; + let size = terminal_size(); + if let Some((Width(w), Height(_))) = size { + std::cmp::min(w as usize, 80) + } else { + 80 + } +}