aboutsummaryrefslogtreecommitdiff
path: root/planetwars-cli/src
diff options
context:
space:
mode:
authorIlion Beyst <ilion.beyst@gmail.com>2021-12-26 22:00:20 +0100
committerIlion Beyst <ilion.beyst@gmail.com>2021-12-26 22:00:20 +0100
commit31b439ee313c9268ac338dd130390d4f7200e693 (patch)
tree75b3905deacdd849d5fb4fab7e28ed3bf366151b /planetwars-cli/src
parent0d03a0fbc214dd3fb9a8af562f9d88cccaf5f2c0 (diff)
downloadplanetwars.dev-31b439ee313c9268ac338dd130390d4f7200e693.tar.xz
planetwars.dev-31b439ee313c9268ac338dd130390d4f7200e693.zip
rebrand project to workspace
Diffstat (limited to 'planetwars-cli/src')
-rw-r--r--planetwars-cli/src/commands/init.rs4
-rw-r--r--planetwars-cli/src/commands/mod.rs2
-rw-r--r--planetwars-cli/src/commands/run_match.rs18
-rw-r--r--planetwars-cli/src/commands/serve.rs4
-rw-r--r--planetwars-cli/src/lib.rs6
-rw-r--r--planetwars-cli/src/web/mod.rs14
6 files changed, 24 insertions, 24 deletions
diff --git a/planetwars-cli/src/commands/init.rs b/planetwars-cli/src/commands/init.rs
index 42491bc..3c9cf08 100644
--- a/planetwars-cli/src/commands/init.rs
+++ b/planetwars-cli/src/commands/init.rs
@@ -5,7 +5,7 @@ use futures::io;
#[derive(Parser)]
pub struct InitCommand {
- /// project root directory
+ /// workspace root directory
path: String,
}
@@ -29,7 +29,7 @@ impl InitCommand {
std::fs::create_dir_all(path.join("bots/simplebot"))?;
// create files
- copy_asset!(path, "pw_project.toml");
+ copy_asset!(path, "pw_workspace.toml");
copy_asset!(path.join("maps"), "hex.json");
copy_asset!(path.join("bots/simplebot"), "simplebot.py");
diff --git a/planetwars-cli/src/commands/mod.rs b/planetwars-cli/src/commands/mod.rs
index 6606c77..db0be21 100644
--- a/planetwars-cli/src/commands/mod.rs
+++ b/planetwars-cli/src/commands/mod.rs
@@ -27,7 +27,7 @@ impl Cli {
#[derive(Subcommand)]
enum Command {
- /// Initialize a new project
+ /// Initialize a new workspace
Init(init::InitCommand),
/// Run a match
RunMatch(run_match::RunMatchCommand),
diff --git a/planetwars-cli/src/commands/run_match.rs b/planetwars-cli/src/commands/run_match.rs
index a5512f4..039d89a 100644
--- a/planetwars-cli/src/commands/run_match.rs
+++ b/planetwars-cli/src/commands/run_match.rs
@@ -7,7 +7,7 @@ use crate::match_runner;
use crate::match_runner::MatchBot;
use crate::match_runner::MatchConfig;
use crate::resolve_bot_config;
-use crate::ProjectConfig;
+use crate::WorkspaceConfig;
#[derive(Parser)]
pub struct RunMatchCommand {
@@ -19,24 +19,24 @@ pub struct RunMatchCommand {
impl RunMatchCommand {
pub async fn run(self) -> io::Result<()> {
- let project_dir = env::current_dir().unwrap();
+ let workspace_root = env::current_dir().unwrap();
- let config_path = project_dir.join("pw_project.toml");
+ let config_path = workspace_root.join("pw_workspace.toml");
- let map_path = project_dir.join(format!("maps/{}.json", self.map));
+ let map_path = workspace_root.join(format!("maps/{}.json", self.map));
let timestamp = chrono::Local::now().format("%Y-%m-%d-%H-%M-%S");
- let log_path = project_dir.join(format!("matches/{}.log", timestamp));
+ let log_path = workspace_root.join(format!("matches/{}.log", timestamp));
let config_str = std::fs::read_to_string(config_path).unwrap();
- let project_config: ProjectConfig = toml::from_str(&config_str).unwrap();
+ let workspace_config: WorkspaceConfig = toml::from_str(&config_str).unwrap();
let players = self
.bots
.into_iter()
.map(|bot_name| {
- let bot_config = project_config.bots.get(&bot_name).unwrap().clone();
- let resolved_config = resolve_bot_config(&project_dir, bot_config);
+ let bot_config = workspace_config.bots.get(&bot_name).unwrap().clone();
+ let resolved_config = resolve_bot_config(&workspace_root, bot_config);
MatchBot {
name: bot_name,
bot_config: resolved_config,
@@ -54,7 +54,7 @@ impl RunMatchCommand {
match_runner::run_match(match_config).await;
println!("match completed successfully");
// TODO: don't hardcode match path.
- // maybe print the match result as well?
+ // maybe print the match result as well?
println!("wrote match log to matches/{}.log", timestamp);
Ok(())
}
diff --git a/planetwars-cli/src/commands/serve.rs b/planetwars-cli/src/commands/serve.rs
index 2a2e59b..a078c83 100644
--- a/planetwars-cli/src/commands/serve.rs
+++ b/planetwars-cli/src/commands/serve.rs
@@ -10,9 +10,9 @@ pub struct ServeCommand;
impl ServeCommand {
pub async fn run(self) -> io::Result<()> {
- let project_dir = env::current_dir().unwrap();
+ let workspace_root = env::current_dir().unwrap();
- web::run(project_dir).await;
+ web::run(workspace_root).await;
Ok(())
}
}
diff --git a/planetwars-cli/src/lib.rs b/planetwars-cli/src/lib.rs
index de9905d..b71164f 100644
--- a/planetwars-cli/src/lib.rs
+++ b/planetwars-cli/src/lib.rs
@@ -9,7 +9,7 @@ use std::collections::HashMap;
use std::path::{Path, PathBuf};
#[derive(Serialize, Deserialize, Debug)]
-struct ProjectConfig {
+struct WorkspaceConfig {
bots: HashMap<String, BotConfig>,
}
@@ -27,8 +27,8 @@ pub async fn run() {
}
}
-fn resolve_bot_config(project_dir: &Path, config: BotConfig) -> BotConfig {
- let mut path = PathBuf::from(project_dir);
+fn resolve_bot_config(workspace_dir: &Path, config: BotConfig) -> BotConfig {
+ let mut path = PathBuf::from(workspace_dir);
path.push(&config.path);
BotConfig {
path: path.to_str().unwrap().to_string(),
diff --git a/planetwars-cli/src/web/mod.rs b/planetwars-cli/src/web/mod.rs
index cd94f5e..66d4218 100644
--- a/planetwars-cli/src/web/mod.rs
+++ b/planetwars-cli/src/web/mod.rs
@@ -21,17 +21,17 @@ use std::{
use crate::match_runner::MatchMeta;
struct State {
- project_root: PathBuf,
+ workspace_root: PathBuf,
}
impl State {
- fn new(project_root: PathBuf) -> Self {
- Self { project_root }
+ fn new(workspace_root: PathBuf) -> Self {
+ Self { workspace_root }
}
}
-pub async fn run(project_root: PathBuf) {
- let shared_state = Arc::new(State::new(project_root));
+pub async fn run(workspace_root: PathBuf) {
+ let shared_state = Arc::new(State::new(workspace_root));
// build our application with a route
let app = Router::new()
@@ -59,7 +59,7 @@ struct MatchData {
async fn list_matches(Extension(state): Extension<Arc<State>>) -> Json<Vec<MatchData>> {
let matches = state
- .project_root
+ .workspace_root
.join("matches")
.read_dir()
.unwrap()
@@ -104,7 +104,7 @@ fn read_match_meta(path: &path::Path) -> io::Result<MatchMeta> {
}
async fn get_match(Extension(state): Extension<Arc<State>>, Path(id): Path<String>) -> String {
- let mut match_path = state.project_root.join("matches").join(id);
+ let mut match_path = state.workspace_root.join("matches").join(id);
match_path.set_extension("log");
fs::read_to_string(match_path).unwrap()
}