use super::super::util::AppIdentOpts;
use crate::{commands::AsyncCliCommand, config::WasmerEnv, opts::ListFormatOpts};
#[derive(clap::Parser, Debug)]
pub struct CmdAppVolumesList {
#[clap(flatten)]
fmt: ListFormatOpts,
#[clap(flatten)]
env: WasmerEnv,
#[clap(flatten)]
ident: AppIdentOpts,
}
#[async_trait::async_trait]
impl AsyncCliCommand for CmdAppVolumesList {
type Output = ();
async fn run_async(self) -> Result<(), anyhow::Error> {
let client = self.env.client()?;
let (_ident, app) = self.ident.load_app(&client).await?;
let volumes = super::list_volumes(&client, &app.owner.global_name, &app.name).await?;
if volumes.is_empty() {
eprintln!("App {} has no volumes!", app.name);
} else {
let items: Vec<super::VolumeListItem> =
volumes.iter().map(super::VolumeListItem::from).collect();
println!("{}", self.fmt.format.render(items.as_slice()));
}
Ok(())
}
}