mirror of
https://github.com/TECHNOFAB11/pay-respects.git
synced 2025-12-12 06:20:09 +01:00
fix: not output when sucessfully executed the command
This commit is contained in:
parent
6a1b7fb246
commit
a201c18c01
2 changed files with 10 additions and 5 deletions
|
|
@ -46,11 +46,15 @@ fn main() {
|
||||||
if execution.is_ok() {
|
if execution.is_ok() {
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
|
last_command = corrected_command;
|
||||||
|
let msg = execution.err().unwrap();
|
||||||
|
error_msg = msg.to_lowercase();
|
||||||
|
|
||||||
let retry_message =
|
let retry_message =
|
||||||
format!("{}", "Looking for new suggestion...".cyan().bold());
|
format!("{}", "Looking for new suggestion...".cyan().bold());
|
||||||
|
|
||||||
|
println!("\n{} {}", "ERROR:".red().bold(), msg);
|
||||||
println!("\n{}\n", retry_message);
|
println!("\n{}\n", retry_message);
|
||||||
last_command = corrected_command;
|
|
||||||
error_msg = execution.err().unwrap();
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ use regex_lite::Regex;
|
||||||
use rule_parser::parse_rules;
|
use rule_parser::parse_rules;
|
||||||
|
|
||||||
use crate::files::{get_best_match_file, get_path_files};
|
use crate::files::{get_best_match_file, get_path_files};
|
||||||
use crate::shell::{PRIVILEGE_LIST};
|
use crate::shell::PRIVILEGE_LIST;
|
||||||
|
|
||||||
pub fn suggest_command(shell: &str, last_command: &str, error_msg: &str) -> Option<String> {
|
pub fn suggest_command(shell: &str, last_command: &str, error_msg: &str) -> Option<String> {
|
||||||
let split_command = split_command(last_command);
|
let split_command = split_command(last_command);
|
||||||
|
|
@ -199,7 +199,7 @@ pub fn confirm_suggestion(shell: &str, command: &str, highlighted: &str) -> Resu
|
||||||
.arg("-c")
|
.arg("-c")
|
||||||
.arg(command)
|
.arg(command)
|
||||||
.stdout(Stdio::inherit())
|
.stdout(Stdio::inherit())
|
||||||
.stderr(Stdio::inherit())
|
.stderr(Stdio::piped())
|
||||||
.output()
|
.output()
|
||||||
.expect("failed to execute process");
|
.expect("failed to execute process");
|
||||||
|
|
||||||
|
|
@ -215,7 +215,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::piped())
|
.stdout(Stdio::inherit())
|
||||||
|
.stderr(Stdio::piped())
|
||||||
.output()
|
.output()
|
||||||
.expect("failed to execute process");
|
.expect("failed to execute process");
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue