Skip to main content

systemprompt_cli/commands/core/
mod.rs

1//! `core` command group: the platform's primary domain commands.
2//!
3//! Dispatches the [`CoreCommands`] subgroups — artifacts, content, files,
4//! contexts, skills, plugins, and hooks. On a `--database-url` invocation only
5//! the content and files subgroups are served; the rest require a full
6//! profile context.
7//!
8//! Copyright (c) systemprompt.io — Business Source License 1.1.
9//! See <https://systemprompt.io> for licensing details.
10
11pub mod artifacts;
12pub mod content;
13pub mod contexts;
14pub mod files;
15pub mod hooks;
16pub mod plugins;
17pub mod skills;
18
19use anyhow::Result;
20use clap::Subcommand;
21
22use crate::context::CommandContext;
23
24#[derive(Debug, Subcommand)]
25pub enum CoreCommands {
26    #[command(subcommand, about = "Artifact inspection and debugging")]
27    Artifacts(artifacts::ArtifactsCommands),
28
29    #[command(subcommand, about = "Content management and analytics")]
30    Content(content::ContentCommands),
31
32    #[command(subcommand, about = "File management and uploads")]
33    Files(files::FilesCommands),
34
35    #[command(subcommand, about = "Context management")]
36    Contexts(contexts::ContextsCommands),
37
38    #[command(subcommand, about = "Skill management and database sync")]
39    Skills(skills::SkillsCommands),
40
41    #[command(subcommand, about = "Plugin management and marketplace generation")]
42    Plugins(plugins::PluginsCommands),
43
44    #[command(subcommand, about = "Hook validation and inspection")]
45    Hooks(hooks::HooksCommands),
46}
47
48pub async fn execute(cmd: CoreCommands, ctx: &CommandContext) -> Result<()> {
49    if ctx.is_database_scoped() && !matches!(cmd, CoreCommands::Content(_) | CoreCommands::Files(_))
50    {
51        return Err(crate::shared::database_scoped_command_error());
52    }
53
54    match cmd {
55        CoreCommands::Artifacts(cmd) => artifacts::execute(cmd, ctx).await,
56        CoreCommands::Content(cmd) => content::execute(cmd, ctx).await,
57        CoreCommands::Files(cmd) => files::execute(cmd, ctx).await,
58        CoreCommands::Contexts(cmd) => contexts::execute(cmd, ctx).await,
59        CoreCommands::Skills(cmd) => skills::execute(cmd, ctx),
60        CoreCommands::Plugins(cmd) => plugins::execute(cmd, ctx),
61        CoreCommands::Hooks(cmd) => hooks::execute(cmd, ctx),
62    }
63}