pass lint checks.

This commit is contained in:
Andrés N. Robalino 2019-09-11 22:34:47 -05:00
parent b35549adac
commit c57c0eb371
2 changed files with 25 additions and 11 deletions

View file

@ -122,7 +122,6 @@ fn search_paths() -> Vec<std::path::PathBuf> {
let mut path = std::path::PathBuf::from("."); let mut path = std::path::PathBuf::from(".");
path.push("target"); path.push("target");
path.push("release"); path.push("release");
search_paths.push(path); search_paths.push(path);
} }
@ -137,9 +136,17 @@ fn load_plugins(context: &mut Context) -> Result<(), ShellError> {
}; };
for path in search_paths() { for path in search_paths() {
let pattern = path.join("nu_plugin_[a-z][a-z]*").clone(); let mut pattern = path.to_path_buf();
trace!("Trying {:?}", pattern.display()); #[cfg(windows)]
{
pattern.push(std::path::Path::new("nu_plugin_[a-z]*.[a-z]*"));
}
#[cfg(not(windows))]
{
pattern.push(std::path::Path::new("nu_plugin_[a-z]*"));
}
match glob::glob_with(&pattern.to_string_lossy(), opts) { match glob::glob_with(&pattern.to_string_lossy(), opts) {
Err(_) => {} Err(_) => {}
@ -149,9 +156,16 @@ fn load_plugins(context: &mut Context) -> Result<(), ShellError> {
continue; continue;
} }
trace!("Found {:?}", bin.display()); let bin_name = {
if let Some(name) = bin.file_name() {
let bin_name = bin.file_name().unwrap().to_string_lossy(); match name.to_str() {
Some(raw) => raw,
None => continue,
}
} else {
continue;
}
};
let is_valid_name = bin_name let is_valid_name = bin_name
.chars() .chars()
@ -160,7 +174,8 @@ fn load_plugins(context: &mut Context) -> Result<(), ShellError> {
let is_executable = { let is_executable = {
#[cfg(windows)] #[cfg(windows)]
{ {
bin_name.ends_with(".exe") || bin_name.ends_with(".bat") bin.ends_with(std::path::Path::new(".exe"))
|| bin.ends_with(std::path::Path::new(".bat"))
} }
#[cfg(not(windows))] #[cfg(not(windows))]
@ -170,6 +185,7 @@ fn load_plugins(context: &mut Context) -> Result<(), ShellError> {
}; };
if is_valid_name && is_executable { if is_valid_name && is_executable {
trace!("Trying {:?}", bin.display());
load_plugin(&bin, context)?; load_plugin(&bin, context)?;
} }
} }

View file

@ -10,9 +10,7 @@ fn can_only_apply_one() {
"open caco3_plastics.csv | first 1 | str origin --downcase --upcase" "open caco3_plastics.csv | first 1 | str origin --downcase --upcase"
); );
assert!( assert!(actual.contains("Usage: str field [--downcase|--upcase|--to-int"));
actual.contains("Usage: str field [--downcase|--upcase|--to-int")
);
} }
#[test] #[test]