mirror of
https://git.sr.ht/~nixgoat/vento
synced 2024-11-16 03:53:04 +00:00
src: Supress clippy warnings
Most of them were related to unnecessary borrows, although one was because I pointlessly added a format! inside a println!. Whoops.
This commit is contained in:
parent
4427dadcfc
commit
791cdf3193
|
@ -60,51 +60,48 @@ pub fn undo() -> Result<()> {
|
|||
}
|
||||
|
||||
println!(
|
||||
"✅ {}",
|
||||
format!(
|
||||
"{}{}{}",
|
||||
match contents[3] {
|
||||
"take" => "Take",
|
||||
"drop" => "Drop",
|
||||
"switch" => "Switch",
|
||||
_ => "Unknown",
|
||||
}
|
||||
.bold(),
|
||||
" action undone".green(),
|
||||
match contents[3] {
|
||||
"take" => format!(
|
||||
"{}{}{}{}{}{}{}",
|
||||
" (".green(),
|
||||
contents[1].bold(),
|
||||
", from ".green(),
|
||||
contents[0],
|
||||
" to ".green(),
|
||||
match contents[2] {
|
||||
"active" => contents[2].green(),
|
||||
"inactive" => contents[2].blue(),
|
||||
_ => contents[2].red(),
|
||||
}
|
||||
.bold(),
|
||||
" slot)".green(),
|
||||
),
|
||||
"drop" => format!(
|
||||
"{}{}{}{}{}{}{}",
|
||||
" (".green(),
|
||||
contents[1].bold(),
|
||||
", from ".green(),
|
||||
match contents[2] {
|
||||
"active" => contents[2].green(),
|
||||
"inactive" => contents[2].blue(),
|
||||
_ => contents[2].red(),
|
||||
}
|
||||
.bold(),
|
||||
" slot to ".green(),
|
||||
contents[0],
|
||||
")".green(),
|
||||
),
|
||||
_ => String::from(""),
|
||||
}
|
||||
)
|
||||
"✅ {}{}{}",
|
||||
match contents[3] {
|
||||
"take" => "Take",
|
||||
"drop" => "Drop",
|
||||
"switch" => "Switch",
|
||||
_ => "Unknown",
|
||||
}
|
||||
.bold(),
|
||||
" action undone".green(),
|
||||
match contents[3] {
|
||||
"take" => format!(
|
||||
"{}{}{}{}{}{}{}",
|
||||
" (".green(),
|
||||
contents[1].bold(),
|
||||
", from ".green(),
|
||||
contents[0],
|
||||
" to ".green(),
|
||||
match contents[2] {
|
||||
"active" => contents[2].green(),
|
||||
"inactive" => contents[2].blue(),
|
||||
_ => contents[2].red(),
|
||||
}
|
||||
.bold(),
|
||||
" slot)".green(),
|
||||
),
|
||||
"drop" => format!(
|
||||
"{}{}{}{}{}{}{}",
|
||||
" (".green(),
|
||||
contents[1].bold(),
|
||||
", from ".green(),
|
||||
match contents[2] {
|
||||
"active" => contents[2].green(),
|
||||
"inactive" => contents[2].blue(),
|
||||
_ => contents[2].red(),
|
||||
}
|
||||
.bold(),
|
||||
" slot to ".green(),
|
||||
contents[0],
|
||||
")".green(),
|
||||
),
|
||||
_ => String::from(""),
|
||||
}
|
||||
);
|
||||
|
||||
Ok(())
|
||||
|
|
|
@ -36,7 +36,7 @@ pub fn init() -> Result<()> {
|
|||
let _ = io::stdout().flush();
|
||||
io::stdin().read_line(&mut answer)?;
|
||||
match answer.as_str().trim() {
|
||||
"y" | "Y" => fs::remove_dir_all(&ventodir)?,
|
||||
"y" | "Y" => fs::remove_dir_all(ventodir)?,
|
||||
_ => process::exit(0),
|
||||
};
|
||||
};
|
||||
|
@ -175,9 +175,9 @@ pub fn switch(message: bool) -> Result<()> {
|
|||
|
||||
let rename_error = "Vento was unable to switch slots. Try running \"vento -i\" and try again";
|
||||
|
||||
fs::rename(&active, &temp).context(rename_error)?;
|
||||
fs::rename(&inactive, &active).context(rename_error)?;
|
||||
fs::rename(&temp, &inactive).context(rename_error)?;
|
||||
fs::rename(active, &temp).context(rename_error)?;
|
||||
fs::rename(inactive, active).context(rename_error)?;
|
||||
fs::rename(&temp, inactive).context(rename_error)?;
|
||||
|
||||
common::history(common::HistoryData {
|
||||
path: PathBuf::new(),
|
||||
|
|
|
@ -72,11 +72,11 @@ pub fn take(file: &String, slot: &str, message: bool) -> Result<()> {
|
|||
|
||||
if sourcepath.is_file() | sourcepath.is_symlink() {
|
||||
// Checks the path's file type
|
||||
fs::copy(&file, &destpath)?;
|
||||
fs::remove_file(&file)?;
|
||||
fs::copy(file, &destpath)?;
|
||||
fs::remove_file(file)?;
|
||||
} else if sourcepath.is_dir() {
|
||||
let options = CopyOptions::new();
|
||||
move_dir(&file, &slotdir, &options)?;
|
||||
move_dir(file, &slotdir, &options)?;
|
||||
} else {
|
||||
bail!("{}", "No such file or directory".red());
|
||||
}
|
||||
|
@ -161,7 +161,7 @@ pub fn drop(file: &String, slot: &str, dest: PathBuf, message: bool) -> Result<(
|
|||
} else if sourcepath.is_dir() {
|
||||
let destpath: PathBuf = Path::new(&dest).to_path_buf();
|
||||
let options = CopyOptions::new();
|
||||
move_dir(&sourcepath, &destpath, &options)?;
|
||||
move_dir(&sourcepath, destpath, &options)?;
|
||||
} else {
|
||||
bail!("{}", "No such file or directory".red());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue