added snap support, as well as config checks for snap, aur and pacman

i18n
Rafael Madriz 3 years ago
parent 92e1098854
commit a96d108c26
No known key found for this signature in database
GPG Key ID: A76CA65098D4FA42

@ -1,7 +1,7 @@
mod mods;
use toml;
use serde;
use mods::{clearcache::clearcache, clone::clone, help::help, install::install, search::{a_search, r_search}, uninstall::uninstall, upgrade::upgrade, flatpak::flatpak};
use mods::{clearcache::clearcache, clone::clone, help::help, install::install, search::{a_search, r_search}, uninstall::uninstall, upgrade::upgrade, flatpak::flatpak, snap::snap};
use std::{env, process::exit, process::Command};
#[derive(serde::Deserialize)]
@ -38,7 +38,7 @@ fn main() {
[backends]
pacman = true
flatpak = false
flatpak = true
snap = false
aur = true
@ -56,13 +56,27 @@ fn main() {
let oper = &args[1];
if oper == "-S" {
for arg in env::args().skip(2) {
let out = Command::new("pacman").arg("-Ss").arg(&arg).status().unwrap();
if out.success() {
install(&arg);
if configfile.backends.pacman.unwrap() == true {
let out = Command::new("pacman").arg("-Ss").arg(&arg).status().unwrap();
if out.success() {
install(&arg);
} else {
if configfile.backends.aur.unwrap() == true {
clone(&arg);
} else {
println!("ERROR: the package wasn't found in the repos and aur support is disabled");
println!("Please enable aur support if you wish to check if this package exists in the aur");
exit(1)
}
}
} else if configfile.backends.aur.unwrap() == true {
clone(&arg)
} else {
clone(&arg);
println!("ERROR: it seems like neither pacman, nor aur support is enabled!");
println!("Please enable either one of those option and try again");
exit(1);
}
}
}
} else if oper == "-R" {
for arg in env::args().skip(2) {
uninstall(&arg);
@ -94,10 +108,29 @@ fn main() {
} else {
println!("ERROR: flatpak not found, please install flatpak and try again!");
println!("If you do have flatpak installed, please open an issue on the ame github repo!");
exit(1);
}
} else {
println!("ERROR: flatpak support is disabled in your ame config!");
println!("Enable flatpak support in your configuration and try again!");
exit(1);
}
} else if oper == "-s" {
if configfile.backends.snap.unwrap() == true {
let b = std::path::Path::new("/usr/bin/snap").exists();
if b == true {
for arg in env::args().skip(2) {
snap(&arg)
}
} else {
println!("ERROR: snap not found, please install snap and try again!");
println!("If you do have snap installed, please open an issue on the ame github repo!");
exit(1);
}
} else {
println!("ERROR: snap support is disabled in your ame config!");
println!("Enable snap support in your configuration and try again!");
exit(1);
}
} else {
help();

@ -5,4 +5,5 @@ pub mod install;
pub mod search;
pub mod uninstall;
pub mod upgrade;
pub mod flatpak;
pub mod flatpak;
pub mod snap;

@ -0,0 +1,6 @@
use runas::Command;
pub fn snap(pkg: &str) {
let errstr = format!("Oops.. Something went wrong!");
Command::new("snap").arg("install").arg(&pkg).status().expect(&errstr);
}
Loading…
Cancel
Save