wasmer_cli/commands/app/volumes/
list.rs

1//! List volumes tied to an edge app.
2
3use super::super::util::AppIdentOpts;
4use crate::{commands::AsyncCliCommand, config::WasmerEnv, opts::ListFormatOpts};
5
6/// List the volumes of an app.
7#[derive(clap::Parser, Debug)]
8pub struct CmdAppVolumesList {
9    #[clap(flatten)]
10    fmt: ListFormatOpts,
11
12    #[clap(flatten)]
13    env: WasmerEnv,
14
15    #[clap(flatten)]
16    ident: AppIdentOpts,
17}
18
19#[async_trait::async_trait]
20impl AsyncCliCommand for CmdAppVolumesList {
21    type Output = ();
22
23    async fn run_async(self) -> Result<(), anyhow::Error> {
24        let client = self.env.client()?;
25
26        let (_ident, app) = self.ident.load_app(&client).await?;
27        let volumes = super::list_volumes(&client, &app.owner.global_name, &app.name).await?;
28
29        if volumes.is_empty() {
30            eprintln!("App {} has no volumes!", app.name);
31        } else {
32            let items: Vec<super::VolumeListItem> =
33                volumes.iter().map(super::VolumeListItem::from).collect();
34            println!("{}", self.fmt.format.render(items.as_slice()));
35        }
36
37        Ok(())
38    }
39}