aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--planetwars-cli/README.md4
-rw-r--r--planetwars-cli/assets/pw_workspace.toml (renamed from planetwars-cli/assets/pw_project.toml)0
-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
8 files changed, 26 insertions, 26 deletions
diff --git a/planetwars-cli/README.md b/planetwars-cli/README.md
index 72572d2..763a3b1 100644
--- a/planetwars-cli/README.md
+++ b/planetwars-cli/README.md
@@ -4,7 +4,7 @@ Tools for developping planetwars bots locally.
## Getting started
-1. Initialize your project directory: `pwcli init-project my_project`
-2. Enter your fresh project: `cd my_project`
+1. Initialize your workspace directory: `pwcli init my_workspace`
+2. Enter your fresh workspace: `cd my_workspace`
3. Run an example match: `pwcli run-match hex simplebot simplebot`
4. View your match in the web UI: `pwcli serve`
diff --git a/planetwars-cli/assets/pw_project.toml b/planetwars-cli/assets/pw_workspace.toml
index 85a4ab6..85a4ab6 100644
--- a/planetwars-cli/assets/pw_project.toml
+++ b/planetwars-cli/assets/pw_workspace.toml
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()
}