Skip to main content

systemprompt_cli/commands/core/
mod.rs

1pub mod artifacts;
2pub mod content;
3pub mod contexts;
4pub mod files;
5pub mod hooks;
6pub mod plugins;
7pub mod skills;
8
9use anyhow::Result;
10use clap::Subcommand;
11use systemprompt_runtime::DatabaseContext;
12
13use crate::CliConfig;
14
15#[derive(Debug, Subcommand)]
16pub enum CoreCommands {
17    #[command(subcommand, about = "Artifact inspection and debugging")]
18    Artifacts(artifacts::ArtifactsCommands),
19
20    #[command(subcommand, about = "Content management and analytics")]
21    Content(content::ContentCommands),
22
23    #[command(subcommand, about = "File management and uploads")]
24    Files(files::FilesCommands),
25
26    #[command(subcommand, about = "Context management")]
27    Contexts(contexts::ContextsCommands),
28
29    #[command(subcommand, about = "Skill management and database sync")]
30    Skills(skills::SkillsCommands),
31
32    #[command(subcommand, about = "Plugin management and marketplace generation")]
33    Plugins(plugins::PluginsCommands),
34
35    #[command(subcommand, about = "Hook validation and inspection")]
36    Hooks(hooks::HooksCommands),
37}
38
39pub async fn execute(cmd: CoreCommands, config: &CliConfig) -> Result<()> {
40    match cmd {
41        CoreCommands::Artifacts(cmd) => artifacts::execute(cmd, config).await,
42        CoreCommands::Content(cmd) => content::execute(cmd).await,
43        CoreCommands::Files(cmd) => files::execute(cmd, config).await,
44        CoreCommands::Contexts(cmd) => contexts::execute(cmd, config).await,
45        CoreCommands::Skills(cmd) => skills::execute(cmd).await,
46        CoreCommands::Plugins(cmd) => plugins::execute(cmd),
47        CoreCommands::Hooks(cmd) => hooks::execute(cmd),
48    }
49}
50
51pub async fn execute_with_db(
52    cmd: CoreCommands,
53    db_ctx: &DatabaseContext,
54    config: &CliConfig,
55) -> Result<()> {
56    match cmd {
57        CoreCommands::Content(cmd) => content::execute_with_db(cmd, db_ctx, config).await,
58        CoreCommands::Files(cmd) => files::execute_with_db(cmd, db_ctx, config).await,
59        CoreCommands::Artifacts(_)
60        | CoreCommands::Contexts(_)
61        | CoreCommands::Skills(_)
62        | CoreCommands::Plugins(_)
63        | CoreCommands::Hooks(_) => {
64            anyhow::bail!("This command requires full profile context")
65        },
66    }
67}