finalising some stuff
parent
52df05752b
commit
dba4ede596
@ -1,32 +1,38 @@
|
||||
use crate::{info, log, Options};
|
||||
use crate::{crash, info, log, Options};
|
||||
|
||||
pub fn install(mut a: Vec<String>, options: Options) {
|
||||
pub fn install(a: Vec<String>, options: Options) {
|
||||
info(format!("Installing packages {} from repos", &a.join(", ")));
|
||||
let b = a.clone();
|
||||
let mut opers = vec![];
|
||||
if options.noconfirm {
|
||||
a.push("--noconfirm".to_string());
|
||||
opers.push("--noconfirm".to_string());
|
||||
}
|
||||
if options.asdeps {
|
||||
a.push("--asdeps".to_string());
|
||||
opers.push("--asdeps".to_string());
|
||||
}
|
||||
let verbosity = options.verbosity;
|
||||
if verbosity >= 1 {
|
||||
log(format!("Installing from repos: {:?}", &b));
|
||||
log(format!("Installing from repos: {:?}", &a));
|
||||
}
|
||||
|
||||
let r = runas::Command::new("pacman")
|
||||
.arg("-S")
|
||||
.arg("--needed")
|
||||
.args(&a)
|
||||
.args(&opers)
|
||||
.status()
|
||||
.expect("Something has gone wrong");
|
||||
|
||||
if let Some(x) = r.code() {
|
||||
if verbosity >= 1 {
|
||||
log(format!(
|
||||
"Installing packages: {:?} exited with code {}",
|
||||
&b, x
|
||||
));
|
||||
}
|
||||
if r.code() != Some(0) {
|
||||
crash(
|
||||
format!(
|
||||
"An error occured while installing packages: {}, aborting",
|
||||
a.join(", ")
|
||||
),
|
||||
1,
|
||||
);
|
||||
}
|
||||
|
||||
if verbosity >= 1 {
|
||||
log(format!("Installing packages: {:?} was successful", &a));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue