always start from the default cfg

pull/14/head
dvkt 5 years ago
parent 17cefcc67f
commit 4c0a2646d2

@ -7,7 +7,11 @@ use std::{
/// phetch will look for this file on load. /// phetch will look for this file on load.
const CONFIG_FILE: &str = "phetch.conf"; const CONFIG_FILE: &str = "phetch.conf";
/// Default start page.
const DEFAULT_START: &str = "gopher://phetch/1/home";
/// Default config. Currently only used internally. /// Default config. Currently only used internally.
#[allow(dead_code)]
const DEFAULT_CONFIG: &str = " const DEFAULT_CONFIG: &str = "
## config file for the phetch gopher client ## config file for the phetch gopher client
## gopher://phkt.io/1/phetch ## gopher://phkt.io/1/phetch
@ -35,7 +39,12 @@ pub struct Config {
impl Default for Config { impl Default for Config {
fn default() -> Self { fn default() -> Self {
parse(DEFAULT_CONFIG).expect("Syntax error in config file") Config {
start: String::from(DEFAULT_START),
tls: false,
tor: false,
wide: false,
}
} }
} }
@ -61,14 +70,9 @@ pub fn exists() -> bool {
/// Parses a phetch config file into a Config struct. /// Parses a phetch config file into a Config struct.
pub fn parse(text: &str) -> Result<Config> { pub fn parse(text: &str) -> Result<Config> {
let mut linenum = 0; let mut linenum = 0;
let mut cfg = Config { let mut cfg = default();
start: String::new(),
tls: false,
tor: false,
wide: false,
};
let mut keys: HashMap<&str, bool> = HashMap::new(); let mut keys: HashMap<&str, bool> = HashMap::new();
for line in text.split_terminator('\n') { for line in text.split_terminator('\n') {
linenum += 1; linenum += 1;

Loading…
Cancel
Save