mirror of
https://github.com/pesde-pkg/pesde.git
synced 2025-04-11 06:10:53 +01:00
Switches the `colored` crate to the `console` crate. Additionally, to optimize the compiled program's size switches the `inquire` crate's backend from `crossterm` to `console`. Console was picked out because we depend on `indicatif` which only supports `console`. Also switches from `winreg` to `windows-registry`, which `reqwest` depends on to optimize size even further. Currently has to duplicate dependencies, as `reqwest` depends on an older version but will become optimized once `reqwest` updates to the latest version of the crate. Signed-off-by: daimond113 <contact@daimond113.com>
26 lines
585 B
Rust
26 lines
585 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 token = match tokens.0.get(&index_url) {
|
|
Some(token) => token,
|
|
None => {
|
|
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(())
|
|
}
|
|
}
|