From e681eb91cd8293cefed983e2a877ab99813ae1c5 Mon Sep 17 00:00:00 2001 From: Ilion Beyst Date: Sat, 25 Dec 2021 20:30:09 +0100 Subject: implement webserver backend --- planetwars-localdev/src/lib.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'planetwars-localdev/src/lib.rs') diff --git a/planetwars-localdev/src/lib.rs b/planetwars-localdev/src/lib.rs index 562e9a6..c64fb55 100644 --- a/planetwars-localdev/src/lib.rs +++ b/planetwars-localdev/src/lib.rs @@ -26,6 +26,8 @@ enum Commands { InitProject(InitProjectCommand), /// Run a match RunMatch(RunMatchCommand), + /// Host local webserver + Serve(ServeCommand), } #[derive(Parser)] @@ -42,6 +44,9 @@ struct InitProjectCommand { path: String, } +#[derive(Parser)] +struct ServeCommand; + #[derive(Serialize, Deserialize, Debug)] struct ProjectConfig { bots: HashMap, @@ -58,6 +63,7 @@ pub async fn run() { let res = match matches.command { Commands::RunMatch(command) => run_match(command).await, Commands::InitProject(command) => init_project(command), + Commands::Serve(_) => run_webserver().await, }; if let Err(err) = res { eprintln!("{}", err); @@ -139,3 +145,11 @@ fn init_project(command: InitProjectCommand) -> io::Result<()> { Ok(()) } + +mod web; +async fn run_webserver() -> io::Result<()> { + let project_dir = env::current_dir().unwrap(); + + web::run(project_dir).await; + Ok(()) +} -- cgit v1.2.3