Use constants in settings rather than hard-coded strings
This commit is contained in:
		| @@ -70,25 +70,25 @@ impl Configuration { | ||||
|         let mut config = Configuration::default(); | ||||
|  | ||||
|         for config_toml in config_tomls { | ||||
|             config.lock_timeout = match config_toml.get("lock-timeout") { | ||||
|             config.lock_timeout = match config_toml.get(LOCK_TIMEOUT) { | ||||
|                 None => config.lock_timeout, | ||||
|                 Some(val) => parse_duration(val.as_str().ok_or(anyhow!("'lock-timeout' must be a duration string like '10m' or '90s'"))?)?, | ||||
|                 Some(val) => parse_duration(val.as_str().ok_or(anyhow!("'{}' must be a duration string like '10m' or '90s'", LOCK_TIMEOUT))?)?, | ||||
|             }; | ||||
|             config.blank_before_locking = match config_toml.get("blank-before-locking") { | ||||
|             config.blank_before_locking = match config_toml.get(BLANK_BEFORE_LOCKING) { | ||||
|                 None => config.blank_before_locking, | ||||
|                 Some(val) => parse_duration(val.as_str().ok_or(anyhow!("'blank-before-locking' must be a duration string like '10m' or '90s'"))?)?, | ||||
|                 Some(val) => parse_duration(val.as_str().ok_or(anyhow!("'{}' must be a duration string like '10m' or '90s'", BLANK_BEFORE_LOCKING))?)?, | ||||
|             }; | ||||
|             config.dialog_backend = match config_toml.get("dialog-backend") { | ||||
|             config.dialog_backend = match config_toml.get(DIALOG_BACKEND) { | ||||
|                 None => config.dialog_backend, | ||||
|                 Some(val) => DialogBackend::try_from(val.as_str().ok_or(anyhow!("'dialog-backend' must be a string"))?)?, | ||||
|                 Some(val) => DialogBackend::try_from(val.as_str().ok_or(anyhow!("'{}' must be a string", DIALOG_BACKEND))?)?, | ||||
|             }; | ||||
|             config.new_login_command = match config_toml.get("new-login-command") { | ||||
|             config.new_login_command = match config_toml.get(NEW_LOGIN_COMMAND) { | ||||
|                 None => config.new_login_command, | ||||
|                 Some(val) => val.try_into().unwrap_or(NewLoginCommand::Auto), | ||||
|             }; | ||||
|             config.handle_brightness_keys = match config_toml.get(HANDLE_BRIGHTNESS_KEYS) { | ||||
|                 None => config.handle_brightness_keys, | ||||
|                 Some(val) => val.as_bool().ok_or(anyhow!("'handle-brightness-keys' must be a boolean"))?, | ||||
|                 Some(val) => val.as_bool().ok_or(anyhow!("'{}' must be a boolean", HANDLE_BRIGHTNESS_KEYS))?, | ||||
|             } | ||||
|         } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user