mirror of
https://github.com/TECHNOFAB11/pay-respects.git
synced 2025-12-11 22:10:09 +01:00
chore: clean
This commit is contained in:
parent
92d14cdf20
commit
c10f08a0c2
5 changed files with 20 additions and 21 deletions
|
|
@ -7,7 +7,7 @@ use inquire::*;
|
|||
|
||||
pub fn suggestion(data: &mut Data) {
|
||||
let shell = data.shell.clone();
|
||||
let mut last_command ;
|
||||
let mut last_command;
|
||||
|
||||
loop {
|
||||
last_command = data.command.clone();
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
use crate::suggestions::*;
|
||||
use crate::shell::Data;
|
||||
use crate::suggestions::*;
|
||||
use pay_respects_parser::parse_rules;
|
||||
|
||||
pub fn match_pattern(
|
||||
executable: &str,
|
||||
data: &mut Data
|
||||
) {
|
||||
pub fn match_pattern(executable: &str, data: &mut Data) {
|
||||
let error_msg = &data.error.clone();
|
||||
let shell = &data.shell.clone();
|
||||
let last_command = &data.command.clone();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::replaces;
|
||||
use crate::suggestions::*;
|
||||
use crate::shell::Data;
|
||||
use crate::suggestions::*;
|
||||
|
||||
#[derive(serde::Deserialize)]
|
||||
struct Rule {
|
||||
|
|
@ -13,10 +13,7 @@ struct MatchError {
|
|||
suggest: Vec<String>,
|
||||
}
|
||||
|
||||
pub fn runtime_match(
|
||||
executable: &str,
|
||||
data: &mut Data,
|
||||
) {
|
||||
pub fn runtime_match(executable: &str, data: &mut Data) {
|
||||
let file = get_rule(executable);
|
||||
if file.is_none() {
|
||||
return;
|
||||
|
|
@ -68,7 +65,7 @@ pub fn runtime_match(
|
|||
shell,
|
||||
last_command,
|
||||
error_msg,
|
||||
&split_command,
|
||||
split_command,
|
||||
) == reverse
|
||||
{
|
||||
continue 'suggest;
|
||||
|
|
@ -83,7 +80,12 @@ pub fn runtime_match(
|
|||
if pure_suggest.contains("{{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,
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -266,11 +266,7 @@ pub fn expand_alias(map: &HashMap<String, String>, command: &str) -> Option<Stri
|
|||
} else {
|
||||
(command, "")
|
||||
};
|
||||
if let Some(expand) = map.get(command) {
|
||||
Some(format!("{} {}", expand, args))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
map.get(command).map(|expand| format!("{} {}", expand, args))
|
||||
}
|
||||
|
||||
pub fn expand_alias_multiline(map: &HashMap<String, String>, command: &str) -> Option<String> {
|
||||
|
|
|
|||
|
|
@ -92,11 +92,15 @@ pub fn select_candidate(data: &mut Data) {
|
|||
.with_answered_prompt_prefix(style)
|
||||
.with_highlighted_option_prefix(style);
|
||||
|
||||
let msg = format!("{} suggestions found:", candidates.len()).bold().blue();
|
||||
let hint = format!("{} {} {}",
|
||||
let msg = format!("{} suggestions found:", candidates.len())
|
||||
.bold()
|
||||
.blue();
|
||||
let hint = format!(
|
||||
"{} {} {}",
|
||||
"[↑/↓]".blue(),
|
||||
t!("confirm-yes").green(),
|
||||
"[Ctrl+C]".red());
|
||||
"[Ctrl+C]".red()
|
||||
);
|
||||
eprintln!("{}", msg);
|
||||
eprintln!("{}", hint);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue