systemprompt_cli/commands/admin/session/
mod.rs1mod list;
4mod login;
5mod logout;
6mod show;
7mod switch;
8
9use anyhow::Result;
10use clap::Subcommand;
11
12use crate::cli_settings::CliConfig;
13use crate::descriptor::{CommandDescriptor, DescribeCommand};
14use crate::shared::render_result;
15
16#[derive(Debug, Subcommand)]
17pub enum SessionCommands {
18 #[command(about = "Show current session and routing info")]
19 Show,
20
21 #[command(about = "Switch to a different profile")]
22 Switch { profile_name: String },
23
24 #[command(about = "List available profiles")]
25 List,
26
27 #[command(about = "Create an admin session for CLI access")]
28 Login(login::LoginArgs),
29
30 #[command(about = "Remove a session")]
31 Logout(logout::LogoutArgs),
32}
33
34impl DescribeCommand for SessionCommands {
35 fn descriptor(&self) -> CommandDescriptor {
36 match self {
37 Self::Login(_) | Self::Switch { .. } => CommandDescriptor::PROFILE_AND_SECRETS,
38 Self::Show | Self::List | Self::Logout(_) => CommandDescriptor::NONE,
39 }
40 }
41}
42
43pub async fn execute(cmd: SessionCommands, config: &CliConfig) -> Result<()> {
44 match cmd {
45 SessionCommands::Show => show::execute(config),
46 SessionCommands::Switch { profile_name } => switch::execute(&profile_name, config).await,
47 SessionCommands::List => {
48 list::execute(config);
49 Ok(())
50 },
51 SessionCommands::Login(args) => {
52 let result = login::execute(args, config).await?;
53 render_result(&result);
54 Ok(())
55 },
56 SessionCommands::Logout(ref args) => logout::execute(args, config),
57 }
58}