diff --git a/web/src/configuration.rs b/web/src/configuration.rs index 44e38f0..b301a0a 100644 --- a/web/src/configuration.rs +++ b/web/src/configuration.rs @@ -1,3 +1,4 @@ +use pronouns_today::PronounList; use pronouns_today::UserPreferences; use std::fs::OpenOptions; use std::fs::File; @@ -68,6 +69,12 @@ pub struct Run { /// default pronoun probabilites (formatted as a prefstring, like the ones in the /// used in the custom URLs, e.g. "acaqeawdym") pub default_prefstr: Option, + + #[argh(option)] + /// the pronouns to be supported by the server. see configuration file documentation + /// for warnings when changing this value. formatted as a list of comma seperated + /// five-form pronouns, e.g. she/her/her/hers/herself,he/him/his/his/himself + pub pronouns: Option, } impl Run { @@ -76,7 +83,7 @@ impl Run { /// If `--no-read-cfg` was passed, no config file is present, and there aren't /// enough args to populate the configuration, returns an [`Err`] with a list of /// arguments that were missing. - pub fn load_config(&self) -> Result { + pub fn load_config(self) -> Result { if !self.no_read_cfg { match File::open(&self.config) { Ok(raw_cfg) => { @@ -100,7 +107,7 @@ impl Run { } } else { Ok(Conf::default()) - }.map(|config| config.update_with(&self)) + }.map(|config| config.update_with(self)) } } @@ -117,8 +124,9 @@ pub struct Conf { } impl Conf { - fn update_with(mut self, args: &Run) -> Conf { + fn update_with(mut self, args: Run) -> Conf { self.port = args.port.unwrap_or(self.port); + self.instance_settings.pronoun_list = args.pronouns.map(Into::into).unwrap_or(self.instance_settings.pronoun_list); self } }