aboutsummaryrefslogtreecommitdiff
path: root/planetwars-cli/src/commands/mod.rs
diff options
context:
space:
mode:
authorIlion Beyst <ilion.beyst@gmail.com>2021-12-26 21:54:26 +0100
committerIlion Beyst <ilion.beyst@gmail.com>2021-12-26 21:54:26 +0100
commit0d03a0fbc214dd3fb9a8af562f9d88cccaf5f2c0 (patch)
treeaa93706592a050fc01a220546b73889faeab80fe /planetwars-cli/src/commands/mod.rs
parentc04d4a449bd147c632c0b6ceae04f0514803b66f (diff)
downloadplanetwars.dev-0d03a0fbc214dd3fb9a8af562f9d88cccaf5f2c0.tar.xz
planetwars.dev-0d03a0fbc214dd3fb9a8af562f9d88cccaf5f2c0.zip
refactor commands
Diffstat (limited to 'planetwars-cli/src/commands/mod.rs')
-rw-r--r--planetwars-cli/src/commands/mod.rs36
1 files changed, 36 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..6606c77
--- /dev/null
+++ b/planetwars-cli/src/commands/mod.rs
@@ -0,0 +1,36 @@
+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,
+ }
+ }
+}
+
+#[derive(Subcommand)]
+enum Command {
+ /// Initialize a new project
+ Init(init::InitCommand),
+ /// Run a match
+ RunMatch(run_match::RunMatchCommand),
+ /// Host local webserver
+ Serve(serve::ServeCommand),
+}