Configurable config file
This commit is contained in:
+10
-2
@@ -35,8 +35,16 @@ fn main() {
|
|||||||
// Skip program name
|
// Skip program name
|
||||||
_ = args.next();
|
_ = args.next();
|
||||||
|
|
||||||
|
let mut config_file = format!("{}/wldash/config.yml", xdg::config_folder());
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
match args.next() {
|
match args.next() {
|
||||||
|
Some(ref s) if s == "--config" => {
|
||||||
|
match args.next() {
|
||||||
|
Some(ref s) => config_file = s.clone(),
|
||||||
|
None => panic!("missing argument to --config"),
|
||||||
|
}
|
||||||
|
}
|
||||||
Some(ref s) if s == "generate" => {
|
Some(ref s) if s == "generate" => {
|
||||||
let config = match args.next() {
|
let config = match args.next() {
|
||||||
Some(ref s) if s == "v1" => Config::generate_v1(),
|
Some(ref s) if s == "v1" => Config::generate_v1(),
|
||||||
@@ -45,7 +53,7 @@ fn main() {
|
|||||||
None => Config::generate_v2(false),
|
None => Config::generate_v2(false),
|
||||||
Some(s) => panic!("unknown argument: {}", s),
|
Some(s) => panic!("unknown argument: {}", s),
|
||||||
};
|
};
|
||||||
match File::create(format!("{}/wldash/config.yml", xdg::config_folder())) {
|
match File::create(config_file) {
|
||||||
Ok(f) => serde_yaml::to_writer(f, &config).unwrap(),
|
Ok(f) => serde_yaml::to_writer(f, &config).unwrap(),
|
||||||
Err(_) => panic!("uh"),
|
Err(_) => panic!("uh"),
|
||||||
}
|
}
|
||||||
@@ -131,7 +139,7 @@ fn main() {
|
|||||||
|
|
||||||
let mut fm = FontMap::new();
|
let mut fm = FontMap::new();
|
||||||
|
|
||||||
let config: Config = match File::open(format!("{}/wldash/config.yml", xdg::config_folder())) {
|
let config: Config = match File::open(config_file) {
|
||||||
Ok(f) => serde_yaml::from_reader(f).unwrap(),
|
Ok(f) => serde_yaml::from_reader(f).unwrap(),
|
||||||
Err(_) => panic!("configuration file missing"),
|
Err(_) => panic!("configuration file missing"),
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user