wasmer_cli/commands/app/version/
get.rs

1use anyhow::Context;
2
3use crate::{
4    commands::{AsyncCliCommand, app::util::AppIdentOpts},
5    config::WasmerEnv,
6    opts::ItemFormatOpts,
7    utils::render::ItemFormat,
8};
9
10/// Show information for a specific app version.
11#[derive(clap::Parser, Debug)]
12pub struct CmdAppVersionGet {
13    #[clap(flatten)]
14    pub env: WasmerEnv,
15
16    #[clap(flatten)]
17    pub fmt: ItemFormatOpts,
18
19    /// *Name* of the version - NOT the unique version id!
20    #[clap(long)]
21    pub name: String,
22
23    #[clap(flatten)]
24    #[allow(missing_docs)]
25    pub ident: AppIdentOpts,
26}
27
28#[async_trait::async_trait]
29impl AsyncCliCommand for CmdAppVersionGet {
30    type Output = ();
31
32    async fn run_async(self) -> Result<(), anyhow::Error> {
33        let client = self.env.client()?;
34        let (_ident, app) = self.ident.load_app(&client).await?;
35
36        let version = wasmer_backend_api::query::get_app_version(
37            &client,
38            app.owner.global_name,
39            app.name,
40            self.name.clone(),
41        )
42        .await?
43        .with_context(|| format!("Could not find app version '{}'", self.name))?;
44
45        println!(
46            "{}",
47            self.fmt.get_with_default(ItemFormat::Yaml).render(&version)
48        );
49
50        Ok(())
51    }
52}