2021-12-25 13:45:05 +00:00
|
|
|
use serde::Deserialize;
|
|
|
|
|
2021-12-26 20:54:26 +00:00
|
|
|
mod commands;
|
2021-12-25 13:45:05 +00:00
|
|
|
mod match_runner;
|
2021-12-26 20:54:26 +00:00
|
|
|
mod web;
|
2021-12-25 13:45:05 +00:00
|
|
|
|
|
|
|
use serde::Serialize;
|
|
|
|
use std::collections::HashMap;
|
|
|
|
use std::path::{Path, PathBuf};
|
2021-12-25 19:30:09 +00:00
|
|
|
|
2021-12-25 13:45:05 +00:00
|
|
|
#[derive(Serialize, Deserialize, Debug)]
|
2021-12-26 21:00:20 +00:00
|
|
|
struct WorkspaceConfig {
|
2021-12-25 13:45:05 +00:00
|
|
|
bots: HashMap<String, BotConfig>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
|
|
|
pub struct BotConfig {
|
|
|
|
path: String,
|
|
|
|
argv: Vec<String>,
|
|
|
|
}
|
|
|
|
|
|
|
|
pub async fn run() {
|
2021-12-26 20:54:26 +00:00
|
|
|
let res = commands::Cli::run().await;
|
2021-12-25 13:45:05 +00:00
|
|
|
if let Err(err) = res {
|
|
|
|
eprintln!("{}", err);
|
|
|
|
std::process::exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-26 21:00:20 +00:00
|
|
|
fn resolve_bot_config(workspace_dir: &Path, config: BotConfig) -> BotConfig {
|
|
|
|
let mut path = PathBuf::from(workspace_dir);
|
2021-12-25 13:45:05 +00:00
|
|
|
path.push(&config.path);
|
|
|
|
BotConfig {
|
|
|
|
path: path.to_str().unwrap().to_string(),
|
|
|
|
argv: config.argv,
|
|
|
|
}
|
|
|
|
}
|