systemprompt_cli/commands/cloud/auth/
mod.rs1mod login;
2mod logout;
3mod whoami;
4
5use crate::cli_settings::CliConfig;
6use anyhow::Result;
7use clap::{Args, Subcommand};
8
9use super::Environment;
10
11#[derive(Debug, Clone, Copy, Subcommand)]
12pub enum AuthCommands {
13 #[command(about = "Authenticate with systemprompt.io Cloud via OAuth")]
14 Login {
15 #[arg(value_enum, default_value_t = Environment::default(), hide = true)]
16 environment: Environment,
17 },
18
19 #[command(about = "Clear saved cloud credentials")]
20 Logout(LogoutArgs),
21
22 #[command(about = "Show current authenticated user and token status")]
23 Whoami,
24}
25
26#[derive(Debug, Clone, Copy, Args)]
27pub struct LogoutArgs {
28 #[arg(short = 'y', long, help = "Skip confirmation prompts")]
29 pub yes: bool,
30}
31
32pub async fn execute(cmd: AuthCommands, config: &CliConfig) -> Result<()> {
33 match cmd {
34 AuthCommands::Login { environment } => login::execute(environment, config).await,
35 AuthCommands::Logout(args) => logout::execute(args, config),
36 AuthCommands::Whoami => whoami::execute().await,
37 }
38}