diff options
Diffstat (limited to 'planetwars-localdev/src/lib.rs')
-rw-r--r-- | planetwars-localdev/src/lib.rs | 14 |
1 files changed, 14 insertions, 0 deletions
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<String, BotConfig>, @@ -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(()) +} |