mirror of
https://github.com/TECHNOFAB11/pay-respects.git
synced 2026-02-02 07:35:10 +01:00
chore: cleanup
This commit is contained in:
parent
81ca8d6e98
commit
5791c2fc20
6 changed files with 28 additions and 31 deletions
|
|
@ -32,7 +32,6 @@ pub fn suggest_candidates(data: &mut Data) {
|
||||||
|
|
||||||
thread::scope(|s| {
|
thread::scope(|s| {
|
||||||
s.spawn(|| {
|
s.spawn(|| {
|
||||||
let command = &data.command;
|
|
||||||
for module in modules {
|
for module in modules {
|
||||||
let new_candidates = module_output(&data, module);
|
let new_candidates = module_output(&data, module);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,8 @@
|
||||||
|
|
||||||
### Entertaining
|
### Entertaining
|
||||||
|
|
||||||
- Select library that works well with `pay-respects`' complex difference highlighting
|
- Select library that:
|
||||||
|
- Works well with `pay-respects`' complex difference highlighting
|
||||||
|
- Supports adding candidates dynamically
|
||||||
- NLP model as alternative to the current LLM based AI requests
|
- NLP model as alternative to the current LLM based AI requests
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -147,19 +147,12 @@ fn eval_suggest(
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_rule(executable: &str) -> Option<String> {
|
fn get_rule(executable: &str) -> Option<String> {
|
||||||
let xdg_config_home = if cfg!(windows) {
|
|
||||||
std::env::var("APPDATA").unwrap()
|
|
||||||
} else {
|
|
||||||
std::env::var("XDG_CONFIG_HOME")
|
|
||||||
.unwrap_or_else(|_| std::env::var("HOME").unwrap() + "/.config")
|
|
||||||
};
|
|
||||||
|
|
||||||
let user_rule_dir = format!("{}/pay-respects/rules", xdg_config_home);
|
#[cfg(windows)]
|
||||||
let user_rule_file = format!("{}/{}.toml", user_rule_dir, executable);
|
let xdg_config_home = std::env::var("APPDATA").unwrap();
|
||||||
|
#[cfg(not(windows))]
|
||||||
if std::path::Path::new(&user_rule_file).exists() {
|
let xdg_config_home = std::env::var("XDG_CONFIG_HOME")
|
||||||
return Some(user_rule_file);
|
.unwrap_or_else(|_| std::env::var("HOME").unwrap() + "/.config");
|
||||||
}
|
|
||||||
|
|
||||||
let check_dirs = |dirs: &[&str]| -> Option<String> {
|
let check_dirs = |dirs: &[&str]| -> Option<String> {
|
||||||
for dir in dirs {
|
for dir in dirs {
|
||||||
|
|
@ -172,6 +165,11 @@ fn get_rule(executable: &str) -> Option<String> {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if let Some(file) = check_dirs(&[&xdg_config_home]) {
|
||||||
|
return Some(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(windows))] {
|
||||||
let xdg_config_dirs = std::env::var("XDG_CONFIG_DIRS").unwrap_or("/etc/xdg".to_owned());
|
let xdg_config_dirs = std::env::var("XDG_CONFIG_DIRS").unwrap_or("/etc/xdg".to_owned());
|
||||||
let xdg_config_dirs = xdg_config_dirs.split(':').collect::<Vec<&str>>();
|
let xdg_config_dirs = xdg_config_dirs.split(':').collect::<Vec<&str>>();
|
||||||
|
|
||||||
|
|
@ -186,6 +184,6 @@ fn get_rule(executable: &str) -> Option<String> {
|
||||||
if let Some(file) = check_dirs(&xdg_data_dirs) {
|
if let Some(file) = check_dirs(&xdg_data_dirs) {
|
||||||
return Some(file);
|
return Some(file);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ pattern = [
|
||||||
"command not found",
|
"command not found",
|
||||||
"unknown command",
|
"unknown command",
|
||||||
"nu::shell::external_command",
|
"nu::shell::external_command",
|
||||||
"is not recognized as a name of a cmdlet, function, script file, or executable program"
|
"is not recognized as a name of a cmdlet"
|
||||||
]
|
]
|
||||||
suggest = [
|
suggest = [
|
||||||
'''
|
'''
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ workspaces
|
||||||
|
|
||||||
[[match_err]]
|
[[match_err]]
|
||||||
pattern = [
|
pattern = [
|
||||||
"error `install` has been replaced with `add` to add new dependencies."
|
"`install` has been replaced with `add`"
|
||||||
]
|
]
|
||||||
suggest = [
|
suggest = [
|
||||||
'''
|
'''
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,8 @@ use crate::evals::find_similar;
|
||||||
pub fn get_path_files() -> Vec<String> {
|
pub fn get_path_files() -> Vec<String> {
|
||||||
let path_env = path_env();
|
let path_env = path_env();
|
||||||
|
|
||||||
if cfg!(debug_assertions) {
|
#[cfg(debug_assertions)]
|
||||||
eprintln!("path_env: {path_env}");
|
eprintln!("path_env: {path_env}");
|
||||||
}
|
|
||||||
|
|
||||||
let path_env_sep = path_env_sep();
|
let path_env_sep = path_env_sep();
|
||||||
|
|
||||||
|
|
@ -50,9 +49,8 @@ pub fn get_path_files() -> Vec<String> {
|
||||||
|
|
||||||
pub fn best_match_file(input: &str) -> Option<String> {
|
pub fn best_match_file(input: &str) -> Option<String> {
|
||||||
let mut input = input.trim_matches(|c| c == '\'' || c == '"').to_owned();
|
let mut input = input.trim_matches(|c| c == '\'' || c == '"').to_owned();
|
||||||
if cfg!(debug_assertions) {
|
#[cfg(debug_assertions)]
|
||||||
eprintln!("best_match_file input: {input}");
|
eprintln!("best_match_file input: {input}");
|
||||||
}
|
|
||||||
let mut exit_dirs = Vec::new();
|
let mut exit_dirs = Vec::new();
|
||||||
let mut files = loop {
|
let mut files = loop {
|
||||||
match std::fs::read_dir(&input) {
|
match std::fs::read_dir(&input) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue