Added file loader
TODO: Write a parser
This commit is contained in:
parent
c6874f3ef2
commit
a8a7596bdc
@ -1,5 +1,6 @@
|
|||||||
use core::fmt;
|
use core::fmt;
|
||||||
|
use std::fs::File;
|
||||||
|
use std::io::prelude::*;
|
||||||
use untildify;
|
use untildify;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -105,3 +106,12 @@ impl fmt::Display for Config {
|
|||||||
write!(f, "Mycelium Config: X Server: {xserv}, Wallpaper Engine: {wallpaper_engine}, Wallpaper Directories: {wallpaper_dirs}, Monitors: {monitors}", xserv = self.x_server, wallpaper_engine = self.wallpaper_engine, wallpaper_dirs = self.wallpaper_dir, monitors = self.monitors)
|
write!(f, "Mycelium Config: X Server: {xserv}, Wallpaper Engine: {wallpaper_engine}, Wallpaper Directories: {wallpaper_dirs}, Monitors: {monitors}", xserv = self.x_server, wallpaper_engine = self.wallpaper_engine, wallpaper_dirs = self.wallpaper_dir, monitors = self.monitors)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Config {
|
||||||
|
pub fn load_from_file(self, file_path: String) -> String {
|
||||||
|
let mut file = File::open(file_path).unwrap();
|
||||||
|
let mut contents = String::new();
|
||||||
|
file.read_to_string(&mut contents).unwrap();
|
||||||
|
contents.to_string()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -3,5 +3,8 @@ mod config;
|
|||||||
fn main() {
|
fn main() {
|
||||||
let config = config::Config::new();
|
let config = config::Config::new();
|
||||||
|
|
||||||
println!("{}", config);
|
println!(
|
||||||
|
"{}",
|
||||||
|
config.load_from_file("/home/ben/.config/wallpaperctl/wallpaperctl.ini".to_owned())
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user