From c6293d8e328bb96c368921fe922092d4f27f0bc9 Mon Sep 17 00:00:00 2001 From: Ilion Beyst Date: Thu, 21 Jul 2022 19:19:40 +0200 Subject: delete old planetwars-cli code --- planetwars-cli/src/workspace/bot.rs | 50 ------------------------------------- 1 file changed, 50 deletions(-) delete mode 100644 planetwars-cli/src/workspace/bot.rs (limited to 'planetwars-cli/src/workspace/bot.rs') diff --git a/planetwars-cli/src/workspace/bot.rs b/planetwars-cli/src/workspace/bot.rs deleted file mode 100644 index a0ecb90..0000000 --- a/planetwars-cli/src/workspace/bot.rs +++ /dev/null @@ -1,50 +0,0 @@ -use shlex; -use std::fs; -use std::io; -use std::path::{Path, PathBuf}; - -use serde::{Deserialize, Serialize}; - -const BOT_CONFIG_FILENAME: &str = "botconfig.toml"; - -pub struct WorkspaceBot { - pub path: PathBuf, - pub config: BotConfig, -} - -impl WorkspaceBot { - pub fn open(path: &Path) -> io::Result { - let config_path = path.join(BOT_CONFIG_FILENAME); - let config_str = fs::read_to_string(config_path)?; - let bot_config: BotConfig = toml::from_str(&config_str)?; - - Ok(WorkspaceBot { - path: path.to_path_buf(), - config: bot_config, - }) - } -} - -#[derive(Serialize, Deserialize)] -pub struct BotConfig { - pub name: String, - pub run_command: String, - pub build_command: Option, -} - -impl BotConfig { - // TODO: these commands should not be here - pub fn get_run_argv(&self) -> Vec { - // TODO: proper error handling - shlex::split(&self.run_command) - .expect("Failed to parse bot run command. Check for unterminated quotes.") - } - - pub fn get_build_argv(&self) -> Option> { - // TODO: proper error handling - self.build_command.as_ref().map(|cmd| { - shlex::split(cmd) - .expect("Failed to parse bot build command. Check for unterminated quotes.") - }) - } -} -- cgit v1.2.3