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]
noconfirm = false
[aur]
clone_path = "/home/ali/.ame"

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

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