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