use crate::{cmd::AsyncCliCommand, ApiOpts, ListFormatOpts};
#[derive(clap::Parser, Debug)]
pub struct CmdAppList {
#[clap(flatten)]
fmt: ListFormatOpts,
#[clap(flatten)]
api: ApiOpts,
#[clap(short = 'n', long)]
namespace: Option<String>,
#[clap(short = 'a', long)]
all: bool,
}
impl CmdAppList {
async fn run(self) -> Result<(), anyhow::Error> {
let client = self.api.client()?;
let apps = if let Some(ns) = self.namespace {
wasmer_api::backend::namespace_apps(&client, &ns).await?
} else if self.all {
wasmer_api::backend::user_accessible_apps(&client).await?
} else {
wasmer_api::backend::user_apps(&client).await?
};
println!("{}", self.fmt.format.render(&apps));
Ok(())
}
}
impl AsyncCliCommand for CmdAppList {
fn run_async(self) -> futures::future::BoxFuture<'static, Result<(), anyhow::Error>> {
Box::pin(self.run())
}
}