mirror of https://git.sr.ht/~nixgoat/vento
archive: Add install importing
Allows exported installs to be imported using the command `vento -G`. Mind the uppercase "G" there!
This commit is contained in:
parent
13d0889ad1
commit
2a4ee258a3
|
@ -101,3 +101,22 @@ pub fn import_inv(input: PathBuf, slot: &str, message: bool) -> Result<()> {
|
|||
};
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn import_install(input: PathBuf, message: bool) -> Result<()> {
|
||||
let dir: PathBuf = common::env_config()?.vento_dir;
|
||||
|
||||
let tar_xz = File::open(&input)?;
|
||||
let tar = XzDecoder::new(tar_xz);
|
||||
let mut archive = Archive::new(tar);
|
||||
archive.unpack(&dir)?;
|
||||
|
||||
if message {
|
||||
println!(
|
||||
"✅ {} {} {}",
|
||||
"Imported".green(),
|
||||
&input.to_str().unwrap(),
|
||||
"into Vento install".green(),
|
||||
);
|
||||
};
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -71,6 +71,11 @@ fn main() -> Result<()> {
|
|||
2 => throw_error(ErrorType::SpecifyFile)?,
|
||||
_ => throw_error(ErrorType::TooManyArgs)?,
|
||||
},
|
||||
"-G" | "--import-install" => match args.len() {
|
||||
3 => archive::import_install(PathBuf::from(&args[2]), true)?,
|
||||
2 => throw_error(ErrorType::SpecifyFile)?,
|
||||
_ => throw_error(ErrorType::TooManyArgs)?,
|
||||
},
|
||||
"-s" => match args.len() {
|
||||
4 => inv::list(&args[2], &args[3])?,
|
||||
3 => inv::list(&args[2], "")?,
|
||||
|
|
Loading…
Reference in New Issue