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
use crate::{cmd::AsyncCliCommand, ApiOpts, ListFormatOpts};

/// List namespaces.
#[derive(clap::Parser, Debug)]
pub struct CmdNamespaceList {
    #[clap(flatten)]
    fmt: ListFormatOpts,
    #[clap(flatten)]
    api: ApiOpts,
}

impl CmdNamespaceList {
    async fn run(self) -> Result<(), anyhow::Error> {
        let client = self.api.client()?;

        let namespaces = wasmer_api::backend::user_namespaces(&client).await?;

        println!("{}", self.fmt.format.render(&namespaces));

        Ok(())
    }
}

impl AsyncCliCommand for CmdNamespaceList {
    fn run_async(self) -> futures::future::BoxFuture<'static, Result<(), anyhow::Error>> {
        Box::pin(self.run())
    }
}