--- /dev/null
+save_directory = "/home/ian/Rustup/Game/server/save"
f.read_to_string(&mut buf).context("read")?;
let spec : TableSpec = toml::de::from_str(&buf).context("parse")?;
<Result<_,AE>>::Ok(spec)
- })().context("game spec toml").with_context(|| args.file.to_owned())?;
+ })().with_context(|| args.file.to_owned()).context("read game spec")?;
let _chan = connect(&ma)?;
NamedFile::open(format!("{}/{}", template_dir, leaf.safe))
}
+const DEFAULT_CONFIG_FILENAME : &str = "server.toml";
+
#[throws(StartupError)]
fn main() {
+ {
+ let config_filename = env::args().nth(1)
+ .unwrap_or(DEFAULT_CONFIG_FILENAME.to_owned());
+ let mut buf = String::new();
+ File::open(config_filename)?.read_to_string(&mut buf)?;
+ let config = toml::de::from_str(&buf)?;
+ set_config(config);
+ };
+
xxx_global_setup().expect("global setup failed");
let cl = CommandListener::new()?;
GLOBAL.config.read().unwrap().clone()
}
+pub fn set_config(config: ServerConfig) {
+ *GLOBAL.config.write().unwrap() = Arc::new(config)
+}
+
impl Default for ServerConfig {
fn default() -> ServerConfig {
- ServerConfig {
- save_directory: DEFAULT_SAVE_DIRECTORY.to_owned(),
- }
+ toml::de::from_str("").expect("parse empty string as ServerConfig")
}
}