wasmer_cli/commands/namespace/
create.rs

1use crate::{commands::AsyncCliCommand, config::WasmerEnv, opts::ItemFormatOpts};
2
3/// Create a new namespace.
4#[derive(clap::Parser, Debug)]
5pub struct CmdNamespaceCreate {
6    #[clap(flatten)]
7    fmt: ItemFormatOpts,
8
9    #[clap(flatten)]
10    env: WasmerEnv,
11
12    /// Description of the namespace.
13    #[clap(long)]
14    description: Option<String>,
15
16    /// Name of the namespace.
17    name: String,
18}
19
20#[async_trait::async_trait]
21impl AsyncCliCommand for CmdNamespaceCreate {
22    type Output = ();
23
24    async fn run_async(self) -> Result<(), anyhow::Error> {
25        let client = self.env.client()?;
26
27        let vars = wasmer_backend_api::types::CreateNamespaceVars {
28            name: self.name.clone(),
29            description: self.description.clone(),
30        };
31        let namespace = wasmer_backend_api::query::create_namespace(&client, vars).await?;
32
33        println!("{}", self.fmt.get().render(&namespace));
34
35        Ok(())
36    }
37}