apply clippy improvements
This commit is contained in:
parent
83ed7ee559
commit
a175e494a1
4 changed files with 10 additions and 6 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
|
@ -206,7 +206,7 @@ checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89"
|
|||
|
||||
[[package]]
|
||||
name = "mvw"
|
||||
version = "0.1.3"
|
||||
version = "0.1.4"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"dialoguer",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "mvw"
|
||||
version = "0.1.3"
|
||||
version = "0.1.5"
|
||||
edition = "2021"
|
||||
|
||||
[profile.release]
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ impl DirList {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn from_list(list: &Vec<String>) -> Self {
|
||||
pub fn from_list(list: &[String]) -> Self {
|
||||
Self {
|
||||
safe_source: false,
|
||||
noop: false,
|
||||
|
|
@ -85,7 +85,7 @@ impl DirList {
|
|||
let src_len = self.entries.len();
|
||||
let mut intermediate_files: HashMap<String, String> = HashMap::new();
|
||||
|
||||
self.run_basic_checks(&target_list)?;
|
||||
self.run_basic_checks(target_list)?;
|
||||
if ! self.safe_source {
|
||||
println!("Implement check if target files already exist");
|
||||
}
|
||||
|
|
@ -95,7 +95,7 @@ impl DirList {
|
|||
// is the destination already in the source list?
|
||||
// if so, an intermediate file is needed
|
||||
if self.entries.iter().any(|j| j==&target_list.entries[i]) {
|
||||
let unique = Self::get_unique_entry(&target_list);
|
||||
let unique = Self::get_unique_entry(target_list);
|
||||
intermediate_files.insert(unique.clone(), target_list.entries[i].clone());
|
||||
if ! self.noop { fs::rename(&self.entries[i], &unique).expect("failed to rename file"); }
|
||||
if self.verbose { println!("Moving {} -> {}", self.entries[i], unique); }
|
||||
|
|
@ -137,7 +137,7 @@ impl DirList {
|
|||
// Make sure all destination files are unique in target_list
|
||||
let unique_entries = target_list.entries.iter().map(|x| (x, x)).collect::<HashMap<_, _>>();
|
||||
if target_list.entries.len() != unique_entries.len() {
|
||||
let doubles = self.show_doubles(&target_list);
|
||||
let doubles = self.show_doubles(target_list);
|
||||
let error = format!("ERROR: You're trying to move multiple files to the same name.\n{}", doubles);
|
||||
return Err(error);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,6 +38,10 @@ struct Cli {
|
|||
/// Override editor to use
|
||||
#[arg(short, long)]
|
||||
editor: Option<String>,
|
||||
|
||||
// /// Apply substitution pattern(s) instead of using an editor
|
||||
// #[arg(short, long)]
|
||||
// pattern: Option<Vec<String>>,
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue