aboutsummaryrefslogtreecommitdiff
path: root/planetwars-cli/src/commands/build.rs
diff options
context:
space:
mode:
authorIlion Beyst <ilion.beyst@gmail.com>2021-12-28 19:28:19 +0100
committerIlion Beyst <ilion.beyst@gmail.com>2021-12-28 19:28:19 +0100
commitee5af8d07625bfc7ad11b842b3941bb095aa6a6e (patch)
treeb1f21f06a6a45b4b36cfcfa50ea5bd16a3132670 /planetwars-cli/src/commands/build.rs
parent6d176ac99fb096034ff5406700a7921dab48c24f (diff)
downloadplanetwars.dev-ee5af8d07625bfc7ad11b842b3941bb095aa6a6e.tar.xz
planetwars.dev-ee5af8d07625bfc7ad11b842b3941bb095aa6a6e.zip
implement build command
Diffstat (limited to 'planetwars-cli/src/commands/build.rs')
-rw-r--r--planetwars-cli/src/commands/build.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/planetwars-cli/src/commands/build.rs b/planetwars-cli/src/commands/build.rs
new file mode 100644
index 0000000..1df0bb6
--- /dev/null
+++ b/planetwars-cli/src/commands/build.rs
@@ -0,0 +1,27 @@
+use clap::Parser;
+use std::io;
+use tokio::process;
+
+use crate::workspace::Workspace;
+
+#[derive(Parser)]
+pub struct BuildCommand {
+ /// Name of the bot to build
+ bot: String,
+}
+
+impl BuildCommand {
+ pub async fn run(self) -> io::Result<()> {
+ let workspace = Workspace::open_current_dir()?;
+ let bot = workspace.get_bot(&self.bot)?;
+ if let Some(argv) = bot.config.get_build_argv() {
+ process::Command::new(&argv[0])
+ .args(&argv[1..])
+ .current_dir(&bot.path)
+ .spawn()?
+ .wait()
+ .await?;
+ }
+ Ok(())
+ }
+}