wasmer_cli/commands/auth/
whoami.rs1use clap::Parser;
2use colored::Colorize;
3
4use crate::config::WasmerEnv;
5
6use super::AsyncCliCommand;
7
8#[derive(Debug, Parser)]
9pub struct Whoami {
11 #[clap(flatten)]
12 env: WasmerEnv,
13}
14
15#[async_trait::async_trait]
16impl AsyncCliCommand for Whoami {
17 type Output = ();
18
19 async fn run_async(self) -> Result<Self::Output, anyhow::Error> {
21 let client = self.env.client_unauthennticated()?;
22 let host_str = self.env.registry_public_url()?.host_str().unwrap().bold();
23 let user = wasmer_backend_api::query::current_user(&client)
24 .await?
25 .ok_or_else(|| anyhow::anyhow!("Not logged in registry {host_str}"))?;
26 println!(
27 "Logged into registry {host_str} as user {}",
28 user.username.bold()
29 );
30 Ok(())
31 }
32}