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(_) => CommandDescriptor::PROFILE_AND_SECRETS,
38 Self::Show | Self::Switch { .. } | Self::List | Self::Logout(_) => {
39 CommandDescriptor::NONE
40 },
41 }
42 }
43}
44
45pub async fn execute(cmd: SessionCommands, config: &CliConfig) -> Result<()> {
46 match cmd {
47 SessionCommands::Show => show::execute(config),
48 SessionCommands::Switch { profile_name } => switch::execute(&profile_name, config),
49 SessionCommands::List => {
50 list::execute(config);
51 Ok(())
52 },
53 SessionCommands::Login(args) => {
54 let result = login::execute(args, config).await?;
55 render_result(&result);
56 Ok(())
57 },
58 SessionCommands::Logout(ref args) => logout::execute(args, config),
59 }
60}