mirror of
https://git.sr.ht/~nixgoat/vento
synced 2024-11-24 15:55:17 +00:00
Compare commits
2 commits
d0ddc93b47
...
5f5ae6e41e
Author | SHA1 | Date | |
---|---|---|---|
Lux Aliaga | 5f5ae6e41e | ||
Lux Aliaga | 839d4dcc76 |
|
@ -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.clone(),
|
||||
"inactive" | "i" => common::env_config()?.inactive_dir.clone(),
|
||||
"active" | "a" => common::env_config()?.active_dir,
|
||||
"inactive" | "i" => common::env_config()?.inactive_dir,
|
||||
_ => 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.clone(),
|
||||
"inactive" | "i" => common::env_config()?.inactive_dir.clone(),
|
||||
"active" | "a" => common::env_config()?.active_dir,
|
||||
"inactive" | "i" => common::env_config()?.inactive_dir,
|
||||
_ => PathBuf::new(),
|
||||
};
|
||||
|
||||
|
@ -55,20 +55,10 @@ pub fn take(file: &String, slot: &str) -> Result<()> {
|
|||
};
|
||||
|
||||
let sourcepath: PathBuf = Path::new(&file).to_path_buf();
|
||||
let destpath: PathBuf = [
|
||||
&slotdir,
|
||||
&Path::new(
|
||||
&Path::new(&file)
|
||||
.file_name()
|
||||
.unwrap()
|
||||
.to_os_string()
|
||||
.to_str()
|
||||
.unwrap(),
|
||||
)
|
||||
.to_path_buf(),
|
||||
]
|
||||
.iter()
|
||||
.collect();
|
||||
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();
|
||||
|
||||
if Path::exists(&destpath) {
|
||||
// Checks if there's a file with the same name in the inventory.
|
||||
|
@ -89,6 +79,13 @@ 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(())
|
||||
}
|
||||
|
||||
|
@ -105,8 +102,8 @@ pub fn drop(file: &String, slot: &str, dest: PathBuf) -> Result<()> {
|
|||
};
|
||||
|
||||
let slotdir: PathBuf = match slot {
|
||||
"active" | "a" => common::env_config()?.active_dir.clone(),
|
||||
"inactive" | "i" => common::env_config()?.inactive_dir.clone(),
|
||||
"active" | "a" => common::env_config()?.active_dir,
|
||||
"inactive" | "i" => common::env_config()?.inactive_dir,
|
||||
_ => PathBuf::new(),
|
||||
};
|
||||
|
||||
|
@ -124,7 +121,7 @@ pub fn drop(file: &String, slot: &str, dest: PathBuf) -> Result<()> {
|
|||
};
|
||||
|
||||
let sourcepath: PathBuf = [&slotdir, &Path::new(file).to_path_buf()].iter().collect();
|
||||
let destpath: PathBuf = [
|
||||
let mut destpath: PathBuf = [
|
||||
Path::new(&dest).to_path_buf(),
|
||||
Path::new(file).to_path_buf(),
|
||||
]
|
||||
|
@ -147,5 +144,15 @@ 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