Integrated recent updates into my pull request.
Browse files
+12 −8 src/bin/main.rs
| @@ -1,3 +1,4 @@ | |||
| 1 | +use oxwm::errors::ConfigError; | ||
| 1 | use oxwm::errors::MainError; | 2 | use oxwm::errors::MainError; |
| 2 | use std::path::Path; | 3 | use std::path::Path; |
| 3 | use std::path::PathBuf; | 4 | use std::path::PathBuf; |
| @@ -18,14 +19,15 @@ fn main() -> Result<(), MainError> { | |||
| 18 | Args::Error(e) => return Err(e), | 19 | Args::Error(e) => return Err(e), |
| 19 | }; | 20 | }; |
| 20 | 21 | ||
| 21 | - let (config, had_broken_config) = load_config(arguments.get(2))?; | 22 | + let (config, config_warning) = load_config(arguments.get(2))?; |
| 22 | 23 | ||
| 23 | let mut window_manager = match oxwm::window_manager::WindowManager::new(config) { | 24 | let mut window_manager = match oxwm::window_manager::WindowManager::new(config) { |
| 24 | Ok(wm) => wm, | 25 | Ok(wm) => wm, |
| 25 | Err(e) => return Err(MainError::CouldNotStartWm(e)), | 26 | Err(e) => return Err(MainError::CouldNotStartWm(e)), |
| 26 | }; | 27 | }; |
| 27 | 28 | ||
| 28 | - if had_broken_config { | 29 | + if let Some(warning) = config_warning { |
| 30 | + eprintln!("{warning}"); | ||
| 29 | window_manager.show_migration_overlay(); | 31 | window_manager.show_migration_overlay(); |
| 30 | } | 32 | } |
| 31 | 33 | ||
| @@ -46,7 +48,9 @@ fn main() -> Result<(), MainError> { | |||
| 46 | Ok(()) | 48 | Ok(()) |
| 47 | } | 49 | } |
| 48 | 50 | ||
| 49 | -fn load_config(config_path: Option<&String>) -> Result<(oxwm::Config, bool), MainError> { | 51 | +fn load_config( |
| 52 | + config_path: Option<&String>, | ||
| 53 | +) -> Result<(oxwm::Config, Option<ConfigError>), MainError> { | ||
| 50 | let path = match config_path { | 54 | let path = match config_path { |
| 51 | None => { | 55 | None => { |
| 52 | let config_dir = get_config_path()?; | 56 | let config_dir = get_config_path()?; |
| @@ -64,19 +68,19 @@ fn load_config(config_path: Option<&String>) -> Result<(oxwm::Config, bool), Mai | |||
| 64 | 68 | ||
| 65 | let config_directory = path.parent(); | 69 | let config_directory = path.parent(); |
| 66 | 70 | ||
| 67 | - let (mut config, had_broken_config) = | 71 | + let (mut config, config_warning) = |
| 68 | match oxwm::config::parse_lua_config(&config_string, config_directory) { | 72 | match oxwm::config::parse_lua_config(&config_string, config_directory) { |
| 69 | - Ok(config) => (config, false), | 73 | + Ok(config) => (config, None), |
| 70 | - Err(_error) => { | 74 | + Err(warning) => { |
| 71 | let config = match oxwm::config::parse_lua_config(TEMPLATE, None) { | 75 | let config = match oxwm::config::parse_lua_config(TEMPLATE, None) { |
| 72 | Ok(c) => c, | 76 | Ok(c) => c, |
| 73 | Err(e) => return Err(MainError::FailedReadConfigTemplate(e)), | 77 | Err(e) => return Err(MainError::FailedReadConfigTemplate(e)), |
| 74 | }; | 78 | }; |
| 75 | - (config, true) | 79 | + (config, Some(warning)) |
| 76 | } | 80 | } |
| 77 | }; | 81 | }; |
| 78 | config.path = Some(path); | 82 | config.path = Some(path); |
| 79 | - Ok((config, had_broken_config)) | 83 | + Ok((config, config_warning)) |
| 80 | } | 84 | } |
| 81 | 85 | ||
| 82 | fn init_config() -> Result<(), MainError> { | 86 | fn init_config() -> Result<(), MainError> { |