You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
877 B
Rust

use std::fs::File;
use toml::value::{Array, Table};
use serde_derive::{Serialize, Deserialize};
#[derive(Serialize, Deserialize, Debug)]
pub(crate) struct Config {
pub(crate) base_package_path: String,
pub(crate) installation_path: String,
pub(crate) key_verification: bool
}
impl Default for Config {
fn default() -> Self {
Config {
base_package_path: "/packages".to_string(),
installation_path: "/var/gaypk/".to_string(),
key_verification: true
}
}
}
pub(crate) fn read_config() -> Config {
toml::from_str("/cfg/gaypk/config.toml").expect("Parse failed!")
}
pub(crate) fn write_config(cfg: Config) {
let file = File::create(crate::config::read_config().installation_path + "config.toml").expect("Failed to read file");
writeln!(file, toml::to_string_pretty(&cfg).expect("Write failed!"));
}