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 =
28            wasmer_backend_api::query::get_app_volumes(&client, &app.owner.global_name, &app.name)
29                .await?;
30
31        if volumes.is_empty() {
32            eprintln!("App {} has no volumes!", app.name);
33        } else {
34            println!("{}", self.fmt.format.render(volumes.as_slice()));
35        }
36
37        Ok(())
38    }
39}