cargo-helper 1.1.6

A Gui for Cargo with support for vexide
use std::fs::{
    exists,
    read_to_string
};

pub struct Settings {
    pub default_dir: String,
    pub show_hidden: bool
}

impl Settings {
    pub fn new() -> Self {
        if exists("settings.csv").expect("Could not determine the existence of settings") {
            let file = read_to_string("settings.csv").expect("unable to read settings");
            let file_info: Vec<&str> = 
            file
            .lines()
            .nth(1)
            .expect("Could not read the file's contents")
            .split(',')
            .collect();

            Self {
                default_dir: file_info[0].to_string(),
                show_hidden: file_info[1].parse().unwrap_or_else(|_| {
                    false
                })
            }
        } else {
            Self {
                default_dir: "none".to_string(),
                show_hidden: false
            }
        }
    }
}