mirror of
https://git.sr.ht/~nixgoat/vento
synced 2025-07-23 04:50:53 +00:00
Compare commits
No commits in common. "5f5ae6e41eb4335231a94ab5bcc3580ecd7b18c1" and "d0ddc93b4768cda7e32b54473c3154e5f9bf73c3" have entirely different histories.
5f5ae6e41e
...
d0ddc93b47
|
@ -58,8 +58,8 @@ pub fn list(slot: &str, dir: &str) -> Result<()> {
|
|||
}
|
||||
|
||||
let mut slotdir: PathBuf = match slot {
|
||||
"active" | "a" => common::env_config()?.active_dir,
|
||||
"inactive" | "i" => common::env_config()?.inactive_dir,
|
||||
"active" | "a" => common::env_config()?.active_dir.clone(),
|
||||
"inactive" | "i" => common::env_config()?.inactive_dir.clone(),
|
||||
_ => PathBuf::new(),
|
||||
};
|
||||
|
||||
|
|
45
src/item.rs
45
src/item.rs
|
@ -36,8 +36,8 @@ pub fn take(file: &String, slot: &str) -> Result<()> {
|
|||
);
|
||||
};
|
||||
let slotdir: PathBuf = match slot {
|
||||
"active" | "a" => common::env_config()?.active_dir,
|
||||
"inactive" | "i" => common::env_config()?.inactive_dir,
|
||||
"active" | "a" => common::env_config()?.active_dir.clone(),
|
||||
"inactive" | "i" => common::env_config()?.inactive_dir.clone(),
|
||||
_ => PathBuf::new(),
|
||||
};
|
||||
|
||||
|
@ -55,10 +55,20 @@ pub fn take(file: &String, slot: &str) -> Result<()> {
|
|||
};
|
||||
|
||||
let sourcepath: PathBuf = Path::new(&file).to_path_buf();
|
||||
let mut sourcelocation: PathBuf = fs::canonicalize(&sourcepath)?;
|
||||
sourcelocation.pop();
|
||||
let filename = Path::new(&file).file_name().unwrap().to_str().unwrap();
|
||||
let destpath: PathBuf = [&slotdir, &sourcepath].iter().collect();
|
||||
let destpath: PathBuf = [
|
||||
&slotdir,
|
||||
&Path::new(
|
||||
&Path::new(&file)
|
||||
.file_name()
|
||||
.unwrap()
|
||||
.to_os_string()
|
||||
.to_str()
|
||||
.unwrap(),
|
||||
)
|
||||
.to_path_buf(),
|
||||
]
|
||||
.iter()
|
||||
.collect();
|
||||
|
||||
if Path::exists(&destpath) {
|
||||
// Checks if there's a file with the same name in the inventory.
|
||||
|
@ -79,13 +89,6 @@ pub fn take(file: &String, slot: &str) -> Result<()> {
|
|||
bail!("{}", "No such file or directory.".red());
|
||||
}
|
||||
|
||||
println!(
|
||||
"✅ {} {} {} ",
|
||||
"Took".green(),
|
||||
&filename.bold(),
|
||||
format!("from {}", &sourcelocation.to_str().unwrap()).green()
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -102,8 +105,8 @@ pub fn drop(file: &String, slot: &str, dest: PathBuf) -> Result<()> {
|
|||
};
|
||||
|
||||
let slotdir: PathBuf = match slot {
|
||||
"active" | "a" => common::env_config()?.active_dir,
|
||||
"inactive" | "i" => common::env_config()?.inactive_dir,
|
||||
"active" | "a" => common::env_config()?.active_dir.clone(),
|
||||
"inactive" | "i" => common::env_config()?.inactive_dir.clone(),
|
||||
_ => PathBuf::new(),
|
||||
};
|
||||
|
||||
|
@ -121,7 +124,7 @@ pub fn drop(file: &String, slot: &str, dest: PathBuf) -> Result<()> {
|
|||
};
|
||||
|
||||
let sourcepath: PathBuf = [&slotdir, &Path::new(file).to_path_buf()].iter().collect();
|
||||
let mut destpath: PathBuf = [
|
||||
let destpath: PathBuf = [
|
||||
Path::new(&dest).to_path_buf(),
|
||||
Path::new(file).to_path_buf(),
|
||||
]
|
||||
|
@ -144,15 +147,5 @@ pub fn drop(file: &String, slot: &str, dest: PathBuf) -> Result<()> {
|
|||
} else {
|
||||
bail!("{}", "No such file or directory.".red());
|
||||
}
|
||||
|
||||
destpath.pop();
|
||||
|
||||
println!(
|
||||
"✅ {} {} {} ",
|
||||
"Dropped".green(),
|
||||
&file.bold(),
|
||||
format!("into {}", &destpath.to_str().unwrap()).green()
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue