chore: clean

This commit is contained in:
iff 2024-12-07 00:20:00 +01:00
parent 92d14cdf20
commit c10f08a0c2
5 changed files with 20 additions and 21 deletions

View file

@ -1,11 +1,8 @@
use crate::suggestions::*;
use crate::shell::Data; use crate::shell::Data;
use crate::suggestions::*;
use pay_respects_parser::parse_rules; use pay_respects_parser::parse_rules;
pub fn match_pattern( pub fn match_pattern(executable: &str, data: &mut Data) {
executable: &str,
data: &mut Data
) {
let error_msg = &data.error.clone(); let error_msg = &data.error.clone();
let shell = &data.shell.clone(); let shell = &data.shell.clone();
let last_command = &data.command.clone(); let last_command = &data.command.clone();

View file

@ -1,6 +1,6 @@
use crate::replaces; use crate::replaces;
use crate::suggestions::*;
use crate::shell::Data; use crate::shell::Data;
use crate::suggestions::*;
#[derive(serde::Deserialize)] #[derive(serde::Deserialize)]
struct Rule { struct Rule {
@ -13,10 +13,7 @@ struct MatchError {
suggest: Vec<String>, suggest: Vec<String>,
} }
pub fn runtime_match( pub fn runtime_match(executable: &str, data: &mut Data) {
executable: &str,
data: &mut Data,
) {
let file = get_rule(executable); let file = get_rule(executable);
if file.is_none() { if file.is_none() {
return; return;
@ -68,7 +65,7 @@ pub fn runtime_match(
shell, shell,
last_command, last_command,
error_msg, error_msg,
&split_command, split_command,
) == reverse ) == reverse
{ {
continue 'suggest; continue 'suggest;
@ -83,7 +80,12 @@ pub fn runtime_match(
if pure_suggest.contains("{{command}}") { if pure_suggest.contains("{{command}}") {
pure_suggest = pure_suggest.replace("{{command}}", last_command); pure_suggest = pure_suggest.replace("{{command}}", last_command);
} }
data.add_candidate(&eval_suggest(&pure_suggest, last_command, error_msg, shell)); data.add_candidate(&eval_suggest(
&pure_suggest,
last_command,
error_msg,
shell,
));
} }
} }
} }

View file

@ -266,11 +266,7 @@ pub fn expand_alias(map: &HashMap<String, String>, command: &str) -> Option<Stri
} else { } else {
(command, "") (command, "")
}; };
if let Some(expand) = map.get(command) { map.get(command).map(|expand| format!("{} {}", expand, args))
Some(format!("{} {}", expand, args))
} else {
None
}
} }
pub fn expand_alias_multiline(map: &HashMap<String, String>, command: &str) -> Option<String> { pub fn expand_alias_multiline(map: &HashMap<String, String>, command: &str) -> Option<String> {

View file

@ -92,11 +92,15 @@ pub fn select_candidate(data: &mut Data) {
.with_answered_prompt_prefix(style) .with_answered_prompt_prefix(style)
.with_highlighted_option_prefix(style); .with_highlighted_option_prefix(style);
let msg = format!("{} suggestions found:", candidates.len()).bold().blue(); let msg = format!("{} suggestions found:", candidates.len())
let hint = format!("{} {} {}", .bold()
.blue();
let hint = format!(
"{} {} {}",
"[↑/↓]".blue(), "[↑/↓]".blue(),
t!("confirm-yes").green(), t!("confirm-yes").green(),
"[Ctrl+C]".red()); "[Ctrl+C]".red()
);
eprintln!("{}", msg); eprintln!("{}", msg);
eprintln!("{}", hint); eprintln!("{}", hint);