steer_cli/commands/session/
mod.rs1use async_trait::async_trait;
2use eyre::Result;
3
4use super::Command;
5use crate::cli::SessionCommands;
6
7mod create;
8mod delete;
9mod list;
10mod show;
11
12pub use create::CreateSessionCommand;
13pub use delete::DeleteSessionCommand;
14pub use list::ListSessionCommand;
15pub use show::ShowSessionCommand;
16
17pub struct SessionCommand {
18 pub command: SessionCommands,
19 pub remote: Option<String>,
20 pub session_db: Option<std::path::PathBuf>,
21}
22
23#[async_trait]
24impl Command for SessionCommand {
25 async fn execute(&self) -> Result<()> {
26 match &self.command {
28 SessionCommands::List { active, limit } => {
29 let cmd = ListSessionCommand {
30 active: *active,
31 limit: Some(*limit),
32 remote: self.remote.clone(),
33 session_db: self.session_db.clone(),
34 };
35 cmd.execute().await
36 }
37 SessionCommands::Create {
38 session_config,
39 metadata,
40 system_prompt,
41 } => {
42 let cmd = CreateSessionCommand {
43 session_config: session_config.clone(),
44 metadata: metadata.clone(),
45 remote: self.remote.clone(),
46 system_prompt: system_prompt.clone(),
47 session_db: self.session_db.clone(),
48 };
49 cmd.execute().await
50 }
51 SessionCommands::Delete { session_id, force } => {
52 let cmd = DeleteSessionCommand {
53 session_id: session_id.clone(),
54 force: *force,
55 remote: self.remote.clone(),
56 session_db: self.session_db.clone(),
57 };
58 cmd.execute().await
59 }
60 SessionCommands::Show { session_id } => {
61 let cmd = ShowSessionCommand {
62 session_id: session_id.clone(),
63 remote: self.remote.clone(),
64 session_db: self.session_db.clone(),
65 };
66 cmd.execute().await
67 }
68 }
69 }
70}