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