pzzld_server/cli/cmd/
build.rs

1/*
2    Appellation: build <module>
3    Contrib: FL03 <jo3mccain@icloud.com>
4*/
5use crate::{platform::Context, AsyncHandle};
6
7#[derive(
8    Clone,
9    Debug,
10    Default,
11    Eq,
12    Hash,
13    Ord,
14    PartialEq,
15    PartialOrd,
16    clap::Parser,
17    serde::Deserialize,
18    serde::Serialize,
19)]
20pub struct BuildCmd {
21    #[clap(subcommand)]
22    pub args: Option<BuildOpts>,
23    #[clap(long, short)]
24    pub platform: Option<String>,
25    #[clap(long, short)]
26    pub target: Option<String>,
27    #[arg(action = clap::ArgAction::SetTrue, long, short)]
28    pub update: bool,
29}
30
31#[derive(
32    Clone,
33    Debug,
34    Eq,
35    Hash,
36    Ord,
37    PartialEq,
38    PartialOrd,
39    clap::Subcommand,
40    serde::Deserialize,
41    serde::Serialize,
42    strum::EnumIs,
43)]
44#[serde(rename_all = "lowercase")]
45#[strum(serialize_all = "lowercase")]
46pub enum BuildOpts {
47    Wasm,
48}
49
50impl BuildCmd {
51    #[tracing::instrument(skip(self, ctx), name = "handle", target = "build")]
52    pub async fn handle<Ctx>(self, ctx: &mut Ctx) -> <Self as AsyncHandle<Ctx>>::Output
53    where
54        Self: AsyncHandle<Ctx>,
55        Ctx: core::fmt::Debug,
56    {
57        <Self as AsyncHandle<Ctx>>::handle(self, ctx).await
58    }
59}
60
61#[async_trait::async_trait]
62impl AsyncHandle<Context> for BuildCmd {
63    type Output = anyhow::Result<()>;
64
65    async fn handle(self, ctx: &mut Context) -> Self::Output {
66        let _scope = ctx.config().scope();
67        if let Some(args) = self.args {
68            match args {
69                BuildOpts::Wasm => {
70                    tracing::info!("Building for WebAssembly...");
71                }
72            }
73        }
74
75        Ok(())
76    }
77}