aboutsummaryrefslogtreecommitdiff
path: root/planetwars-localdev/src/lib.rs
diff options
context:
space:
mode:
authorIlion Beyst <ilion.beyst@gmail.com>2021-12-25 20:30:09 +0100
committerIlion Beyst <ilion.beyst@gmail.com>2021-12-25 20:30:09 +0100
commite681eb91cd8293cefed983e2a877ab99813ae1c5 (patch)
tree9419f5e11d13775ccfb573ed57938850ae31886e /planetwars-localdev/src/lib.rs
parent003c551e7320912d468b00905da234ad262b5446 (diff)
downloadplanetwars.dev-e681eb91cd8293cefed983e2a877ab99813ae1c5.tar.xz
planetwars.dev-e681eb91cd8293cefed983e2a877ab99813ae1c5.zip
implement webserver backend
Diffstat (limited to 'planetwars-localdev/src/lib.rs')
-rw-r--r--planetwars-localdev/src/lib.rs14
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(())
+}