use clap::{Args, Subcommand};
use crate::cli::GlobalFlags;
pub mod api_key;
pub mod login;
pub mod logout;
pub mod oidc;
pub mod status;
pub mod whoami;
#[derive(Args, Debug, Clone)]
pub struct AuthArgs {
#[command(subcommand)]
pub command: AuthCommand,
}
#[derive(Subcommand, Debug, Clone)]
pub enum AuthCommand {
Login(login::LoginArgs),
Logout(logout::LogoutArgs),
Status,
Whoami,
}
pub async fn run(args: AuthArgs, global: &GlobalFlags) -> anyhow::Result<()> {
let profile = global.resolved_context();
let store = global.credential_store();
match args.command {
AuthCommand::Login(a) => login::run(a, &profile, &store).await,
AuthCommand::Logout(a) => logout::run(a, &profile, &store).await,
AuthCommand::Status => status::run(global, &store),
AuthCommand::Whoami => whoami::run(global, &store).await,
}
}