added feature to print the current config using -Pc

i18n
axtlos 3 years ago
parent 9e565eaffd
commit 2106101a7f

@ -7,7 +7,7 @@ snap = false
aur = true
[pacman]
noconfirm = true
noconfirm = false
[aur]
clone_path = "/home/user/.cache/ame"

@ -1,10 +1,8 @@
mod mods;
use toml;
use serde;
use std::fs::File;
use std::io::prelude::*;
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};
use mods::{clearcache::clearcache, clone::clone, help::help, install::install, search::{a_search, r_search}, uninstall::uninstall, upgrade::upgrade, flatpak::flatpak, snap::snap, config::printconfig};
use std::{fs::File, io::prelude::*, env, process::exit, process::Command};
#[derive(serde::Deserialize)]
struct General {
@ -37,7 +35,6 @@ fn main() {
let mut file = File::open("config.toml").expect("Unable to open the Config file");
let mut config = String::new();
file.read_to_string(&mut config).expect("Unable to read the Config file");
println!("{}", config);
let configfile: General = toml::from_str(&config).unwrap();
if args.len() <= 1 {
@ -114,7 +111,7 @@ fn main() {
let b = std::path::Path::new("/usr/bin/snap").exists();
if b == true {
for arg in env::args().skip(2) {
snap(&arg)
snap(&arg);
}
} else {
println!("ERROR: snap not found, please install snap and try again!");
@ -126,6 +123,8 @@ fn main() {
println!("Enable snap support in your configuration and try again!");
exit(1);
}
} else if oper == "-Pc" {
printconfig();
} else {
help();
exit(0);

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

@ -14,8 +14,8 @@ pub fn clone(pkg: &str) {
Repository::clone(&url, &path).unwrap();
println!("Installing {} ...", pkg);
Command::new("makepkg")
.current_dir(&cachedir)
.arg("-si")
.status()
.expect(&error);
.current_dir(&cachedir)
.arg("-si")
.status()
.expect(&error);
}

@ -0,0 +1,55 @@
use toml;
use serde;
use std::{fs::File, io::prelude::*, env};
#[derive(serde::Deserialize)]
struct General {
cache: Option<String>,
backends: Backends,
pacman: Pacman,
aur: AUR,
}
#[derive(serde::Deserialize)]
struct Backends {
pacman: Option<bool>,
flatpak: Option<bool>,
snap: Option<bool>,
aur: Option<bool>,
}
#[derive(serde::Deserialize)]
struct Pacman {
noconfirm: Option<bool>,
}
#[derive(serde::Deserialize)]
struct AUR {
clone_path: Option<String>,
}
pub fn printconfig() {
let args: Vec<String> = env::args().collect();
let mut file = File::open("config.toml").expect("Unable to open the Config file");
let mut config = String::new();
file.read_to_string(&mut config).expect("Unable to read the Config file");
let configfile: General = toml::from_str(&config).unwrap();
println!("\
General:
Cache directory: {}
Backends:
pacman support: {}
aur support: {}
flatpak support: {}
snap support: {}
Pacman:
noconfirm: {}
aur:
Clone directory: {}", configfile.cache.unwrap(), configfile.backends.pacman.unwrap(), configfile.backends.aur.unwrap(), configfile.backends.flatpak.unwrap(), configfile.backends.snap.unwrap(), configfile.pacman.noconfirm.unwrap(), configfile.aur.clone_path.unwrap())
}

@ -3,8 +3,11 @@ pub fn help() {
Usage:\n
ame -S <pkg> - install a package
ame -f <pkg> - install a package via flatpak
ame -s <pkg> - install a package via snap
ame -R <pkg> - remove a package
ame -Syu - system upgrade
ame -Ss <pkg> - search for a package
ame -Sa <pkg> - search for a package over the aur
ame -Sr <pkg> - search for a package over the repos
ame -Cc - clear package cache")
}
Loading…
Cancel
Save