Skip to main content

systemprompt_cli/commands/core/skills/
mod.rs

1pub mod types;
2
3mod create;
4mod delete;
5mod edit;
6mod list;
7mod show;
8mod status;
9mod sync;
10
11use anyhow::{Context, Result};
12use clap::Subcommand;
13
14use crate::cli_settings::get_global_config;
15use crate::shared::render_result;
16use crate::CliConfig;
17
18#[derive(Debug, Subcommand)]
19pub enum SkillsCommands {
20    #[command(about = "List configured skills")]
21    List(list::ListArgs),
22
23    #[command(about = "Show skill details")]
24    Show(show::ShowArgs),
25
26    #[command(about = "Create new skill")]
27    Create(create::CreateArgs),
28
29    #[command(about = "Edit skill configuration")]
30    Edit(edit::EditArgs),
31
32    #[command(about = "Delete a skill")]
33    Delete(delete::DeleteArgs),
34
35    #[command(about = "Show database sync status")]
36    Status(status::StatusArgs),
37
38    #[command(about = "Sync skills between disk and database")]
39    Sync(sync::SyncArgs),
40}
41
42pub async fn execute(command: SkillsCommands) -> Result<()> {
43    let config = get_global_config();
44    execute_with_config(command, &config).await
45}
46
47pub async fn execute_with_config(command: SkillsCommands, config: &CliConfig) -> Result<()> {
48    match command {
49        SkillsCommands::List(args) => {
50            let result = list::execute(args, config).context("Failed to list skills")?;
51            render_result(&result);
52            Ok(())
53        },
54        SkillsCommands::Show(args) => {
55            let result = show::execute(&args, config).context("Failed to show skill")?;
56            render_result(&result);
57            Ok(())
58        },
59        SkillsCommands::Create(args) => {
60            let result = create::execute(args, config)
61                .await
62                .context("Failed to create skill")?;
63            render_result(&result);
64            Ok(())
65        },
66        SkillsCommands::Edit(args) => {
67            let result = edit::execute(&args, config).context("Failed to edit skill")?;
68            render_result(&result);
69            Ok(())
70        },
71        SkillsCommands::Delete(args) => {
72            let result = delete::execute(args, config).context("Failed to delete skill")?;
73            render_result(&result);
74            Ok(())
75        },
76        SkillsCommands::Status(args) => {
77            let result = status::execute(args, config)
78                .await
79                .context("Failed to get skill status")?;
80            render_result(&result);
81            Ok(())
82        },
83        SkillsCommands::Sync(args) => {
84            let result = sync::execute(args, config)
85                .await
86                .context("Failed to sync skills")?;
87            render_result(&result);
88            Ok(())
89        },
90    }
91}