aboutsummaryrefslogtreecommitdiff
path: root/planetwars-cli/src/commands/mod.rs
blob: 52fed5cf0e7f7ab749c5bf17ba83fd3b018df593 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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),
}