mirror of
https://github.com/TECHNOFAB11/pay-respects.git
synced 2025-12-12 14:30:10 +01:00
feat: redirect all output to stderr
This commit is contained in:
parent
be3bce62a3
commit
e63d55110e
2 changed files with 13 additions and 7 deletions
|
|
@ -24,6 +24,8 @@ mod style;
|
||||||
mod suggestions;
|
mod suggestions;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
colored::control::set_override(true);
|
||||||
|
|
||||||
args::handle_args();
|
args::handle_args();
|
||||||
|
|
||||||
let shell = match std::env::var("_PR_SHELL") {
|
let shell = match std::env::var("_PR_SHELL") {
|
||||||
|
|
@ -59,7 +61,7 @@ fn main() {
|
||||||
format!("{}", "Looking for new suggestion...".cyan().bold());
|
format!("{}", "Looking for new suggestion...".cyan().bold());
|
||||||
|
|
||||||
// println!("\n{} {}", "ERROR:".red().bold(), msg);
|
// println!("\n{} {}", "ERROR:".red().bold(), msg);
|
||||||
println!("\n{}\n", retry_message);
|
eprintln!("\n{}\n", retry_message);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
|
|
@ -68,11 +70,11 @@ fn main() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
println!(
|
eprintln!(
|
||||||
"No correction found for the command: {}\n",
|
"No correction found for the command: {}\n",
|
||||||
last_command.red()
|
last_command.red()
|
||||||
);
|
);
|
||||||
println!(
|
eprintln!(
|
||||||
"If you think there should be a correction, please open an issue or send a pull request!"
|
"If you think there should be a correction, please open an issue or send a pull request!"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
use std::io::stderr;
|
||||||
|
use std::os::fd::AsFd;
|
||||||
use std::process::{exit, Stdio};
|
use std::process::{exit, Stdio};
|
||||||
use std::time::{Duration, Instant};
|
use std::time::{Duration, Instant};
|
||||||
|
|
||||||
|
|
@ -201,8 +203,8 @@ fn compare_string(a: &str, b: &str) -> usize {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn confirm_suggestion(shell: &str, command: &str, highlighted: &str) -> Result<(), String> {
|
pub fn confirm_suggestion(shell: &str, command: &str, highlighted: &str) -> Result<(), String> {
|
||||||
println!("{}\n", highlighted);
|
eprintln!("{}\n", highlighted);
|
||||||
println!("Press enter to execute the suggestion. Or press Ctrl+C to exit.");
|
eprintln!("Press enter to execute the suggestion. Or press Ctrl+C to exit.");
|
||||||
std::io::stdin().read_line(&mut String::new()).unwrap();
|
std::io::stdin().read_line(&mut String::new()).unwrap();
|
||||||
|
|
||||||
for p in PRIVILEGE_LIST {
|
for p in PRIVILEGE_LIST {
|
||||||
|
|
@ -215,7 +217,8 @@ pub fn confirm_suggestion(shell: &str, command: &str, highlighted: &str) -> Resu
|
||||||
.arg(shell)
|
.arg(shell)
|
||||||
.arg("-c")
|
.arg("-c")
|
||||||
.arg(&command)
|
.arg(&command)
|
||||||
.stdout(Stdio::inherit())
|
// .stdout(Stdio::inherit())
|
||||||
|
.stdout(stderr().as_fd().try_clone_to_owned().unwrap())
|
||||||
.stderr(Stdio::inherit())
|
.stderr(Stdio::inherit())
|
||||||
.spawn()
|
.spawn()
|
||||||
.expect("failed to execute process")
|
.expect("failed to execute process")
|
||||||
|
|
@ -245,7 +248,8 @@ pub fn confirm_suggestion(shell: &str, command: &str, highlighted: &str) -> Resu
|
||||||
let process = std::process::Command::new(shell)
|
let process = std::process::Command::new(shell)
|
||||||
.arg("-c")
|
.arg("-c")
|
||||||
.arg(command)
|
.arg(command)
|
||||||
.stdout(Stdio::inherit())
|
// .stdout(Stdio::inherit())
|
||||||
|
.stdout(stderr().as_fd().try_clone_to_owned().unwrap())
|
||||||
.stderr(Stdio::inherit())
|
.stderr(Stdio::inherit())
|
||||||
.spawn()
|
.spawn()
|
||||||
.expect("failed to execute process")
|
.expect("failed to execute process")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue