aboutsummaryrefslogtreecommitdiff
path: root/planetwars-cli/src/commands/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'planetwars-cli/src/commands/mod.rs')
-rw-r--r--planetwars-cli/src/commands/mod.rs40
1 files changed, 40 insertions, 0 deletions
diff --git a/planetwars-cli/src/commands/mod.rs b/planetwars-cli/src/commands/mod.rs
new file mode 100644
index 0000000..52fed5c
--- /dev/null
+++ b/planetwars-cli/src/commands/mod.rs
@@ -0,0 +1,40 @@
+mod build;
+mod init;
+mod run_match;
+mod serve;
+
+use clap::{Parser, Subcommand};
+use std::io;
+
+#[derive(Parser)]
+#[clap(name = "pwcli")]
+#[clap(author, version, about)]
+pub struct Cli {
+ #[clap(subcommand)]
+ command: Command,
+}
+
+impl Cli {
+ pub async fn run() -> io::Result<()> {
+ let cli = Self::parse();
+
+ match cli.command {
+ Command::Init(command) => command.run().await,
+ Command::RunMatch(command) => command.run().await,
+ Command::Serve(command) => command.run().await,
+ Command::Build(command) => command.run().await,
+ }
+ }
+}
+
+#[derive(Subcommand)]
+enum Command {
+ /// Initialize a new workspace
+ Init(init::InitCommand),
+ /// Run a match
+ RunMatch(run_match::RunMatchCommand),
+ /// Host local webserver
+ Serve(serve::ServeCommand),
+ /// Run build command for a bot
+ Build(build::BuildCommand),
+}