systemprompt_cli/commands/core/contexts/
mod.rs1mod create;
2mod delete;
3mod edit;
4mod list;
5mod new;
6mod resolve;
7mod show;
8mod types;
9mod use_context;
10
11use crate::cli_settings::CliConfig;
12use crate::shared::render_result;
13use anyhow::Result;
14use clap::Subcommand;
15
16pub use types::*;
17
18#[derive(Debug, Subcommand)]
19pub enum ContextsCommands {
20 #[command(about = "List all contexts with stats")]
21 List(list::ListArgs),
22
23 #[command(about = "Show context details")]
24 Show(show::ShowArgs),
25
26 #[command(about = "Create a new context")]
27 Create(create::CreateArgs),
28
29 #[command(about = "Rename a context")]
30 Edit(edit::EditArgs),
31
32 #[command(about = "Delete a context")]
33 Delete(delete::DeleteArgs),
34
35 #[command(name = "use", about = "Set session's active context")]
36 Use(use_context::UseArgs),
37
38 #[command(about = "Create a new context and set it as active")]
39 New(new::NewArgs),
40}
41
42pub async fn execute(cmd: ContextsCommands, config: &CliConfig) -> Result<()> {
43 match cmd {
44 ContextsCommands::List(args) => {
45 let result = list::execute(args, config).await?;
46 render_result(&result);
47 },
48 ContextsCommands::Show(args) => {
49 let result = show::execute(args, config).await?;
50 render_result(&result);
51 },
52 ContextsCommands::Create(args) => {
53 let result = create::execute(args, config).await?;
54 render_result(&result);
55 },
56 ContextsCommands::Edit(args) => {
57 let result = edit::execute(args, config).await?;
58 render_result(&result);
59 },
60 ContextsCommands::Delete(args) => {
61 let result = delete::execute(args, config).await?;
62 render_result(&result);
63 },
64 ContextsCommands::Use(args) => {
65 let result = use_context::execute(args, config).await?;
66 render_result(&result);
67 },
68 ContextsCommands::New(args) => {
69 let result = new::execute(args, config).await?;
70 render_result(&result);
71 },
72 }
73 Ok(())
74}