removed useless config option, and added file trying to be opened at error messages for easier debugging

i18n
Rafael Madriz 3 years ago
parent 5ed7c50a36
commit 8ff1faf00f

@ -8,6 +8,3 @@ aur = true
[pacman] [pacman]
noconfirm = false noconfirm = false
[aur]
clone_path = "/home/ali/.ame"

@ -9,7 +9,6 @@ struct General {
cache: Option<String>, cache: Option<String>,
backends: Backends, backends: Backends,
pacman: Pacman, pacman: Pacman,
aur: AUR,
} }
#[derive(serde::Deserialize)] #[derive(serde::Deserialize)]
@ -25,11 +24,6 @@ struct Pacman {
noconfirm: Option<bool>, noconfirm: Option<bool>,
} }
#[derive(serde::Deserialize)]
struct AUR {
clone_path: Option<String>,
}
fn main() { fn main() {
let args: Vec<String> = env::args().collect(); let args: Vec<String> = env::args().collect();
let mut confile = File::open("/etc/ame.toml").expect("Unable to open the Config file, did you delete ame.toml from /etc/??"); let mut confile = File::open("/etc/ame.toml").expect("Unable to open the Config file, did you delete ame.toml from /etc/??");
@ -45,14 +39,12 @@ fn main() {
[pacman] [pacman]
noconfirm = false noconfirm = false
"
[aur] "#, std::env::var("HOME").unwrap());
clone_path = "{}/.cache/ame"
"#, std::env::var("HOME").unwrap(), std::env::var("HOME").unwrap());
let mut configfile: General = toml::from_str(&defaultconfig).unwrap(); let mut configfile: General = toml::from_str(&defaultconfig).unwrap();
if fs::read_to_string("/etc/ame.toml").expect("unable to open config file!") != "" { if fs::read_to_string("/etc/ame.toml").expect("unable to open config file! (/etc/ame.toml)") != "" {
confile.read_to_string(&mut config).expect("Unable to read the Config file"); confile.read_to_string(&mut config).expect("Unable to read the Config file (/etc/ame.toml)");
configfile = toml::from_str(&config).unwrap(); configfile = toml::from_str(&config).unwrap();
} }
@ -61,7 +53,7 @@ fn main() {
exit(1); exit(1);
} }
let oper = &args[1]; let oper = &args[1];
let clone_path=configfile.aur.clone_path.unwrap(); let clone_path=configfile.cache.unwrap();
if oper == "-S" || oper == "ins" || oper == "install" { if oper == "-S" || oper == "ins" || oper == "install" {
for arg in env::args().skip(2) { for arg in env::args().skip(2) {
if configfile.backends.pacman.unwrap() == true { if configfile.backends.pacman.unwrap() == true {

@ -8,7 +8,6 @@ struct General {
cache: Option<String>, cache: Option<String>,
backends: Backends, backends: Backends,
pacman: Pacman, pacman: Pacman,
aur: AUR,
} }
#[derive(serde::Deserialize)] #[derive(serde::Deserialize)]
@ -24,11 +23,6 @@ struct Pacman {
noconfirm: Option<bool>, noconfirm: Option<bool>,
} }
#[derive(serde::Deserialize)]
struct AUR {
clone_path: Option<String>,
}
pub fn printconfig() { pub fn printconfig() {
@ -45,13 +39,10 @@ pub fn printconfig() {
[pacman] [pacman]
noconfirm = false noconfirm = false
"#, std::env::var("HOME").unwrap());
[aur]
clone_path = "{}/.cache/ame"
"#, std::env::var("HOME").unwrap(), std::env::var("HOME").unwrap());
let mut configfile: General = toml::from_str(&defaultconfig).unwrap(); let mut configfile: General = toml::from_str(&defaultconfig).unwrap();
if fs::read_to_string("/etc/ame.toml").expect("unable to open config file!") != "" { if fs::read_to_string("/etc/ame.toml").expect("unable to open config file! (/etc/ame.toml)") != "" {
confile.read_to_string(&mut config).expect("Unable to read the Config file"); confile.read_to_string(&mut config).expect("Unable to read the Config file (/etc/ame.toml)");
configfile = toml::from_str(&config).unwrap(); configfile = toml::from_str(&config).unwrap();
} }
println!("\ println!("\
@ -66,7 +57,5 @@ Backends:
Pacman: Pacman:
noconfirm: {} noconfirm: {}
", configfile.cache.unwrap(), configfile.backends.pacman.unwrap(), configfile.backends.aur.unwrap(), configfile.backends.flatpak.unwrap(), configfile.backends.snap.unwrap(), configfile.pacman.noconfirm.unwrap());
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())
} }
Loading…
Cancel
Save