pesde/src/cli/commands/auth/whoami.rs
daimond113 ff5c2e5d61
refactor: specify many new clippy lints
Adds quite a lot of Clippy lints which fit with my
personal taste for how pesde's codebase should
look like. Stylistic lints are mostly warns, and
behavioural lints are mostly denied.
2025-03-08 22:00:52 +01:00

23 lines
543 B
Rust

use crate::cli::auth::{get_token_login, get_tokens};
use clap::Args;
use console::style;
#[derive(Debug, Args)]
pub struct WhoAmICommand;
impl WhoAmICommand {
pub async fn run(self, index_url: gix::Url, reqwest: reqwest::Client) -> anyhow::Result<()> {
let tokens = get_tokens().await?;
let Some(token) = tokens.0.get(&index_url) else {
println!("not logged in into {index_url}");
return Ok(());
};
println!(
"logged in as {} into {index_url}",
style(get_token_login(&reqwest, token).await?).bold()
);
Ok(())
}
}