Skip to main content

systemprompt_cli/commands/core/skills/
mod.rs

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