wasmer_cli/commands/namespace/
get.rs

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