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