Skip to main content

systemprompt_cli/commands/core/content/files/
mod.rs

1mod featured;
2mod link;
3mod list;
4mod unlink;
5
6use anyhow::{Context, Result};
7use clap::Subcommand;
8
9use crate::shared::render_result;
10use crate::CliConfig;
11
12#[derive(Debug, Subcommand)]
13pub enum ContentFilesCommands {
14    #[command(about = "Link a file to content with a specific role")]
15    Link(link::LinkArgs),
16
17    #[command(about = "Unlink a file from content")]
18    Unlink(unlink::UnlinkArgs),
19
20    #[command(about = "List files attached to content")]
21    List(list::ListArgs),
22
23    #[command(about = "Get or set the featured image for content")]
24    Featured(featured::FeaturedArgs),
25}
26
27pub async fn execute(cmd: ContentFilesCommands, config: &CliConfig) -> Result<()> {
28    match cmd {
29        ContentFilesCommands::Link(args) => {
30            let result = link::execute(args, config)
31                .await
32                .context("Failed to link file to content")?;
33            render_result(&result);
34            Ok(())
35        },
36        ContentFilesCommands::Unlink(args) => {
37            let result = unlink::execute(args, config)
38                .await
39                .context("Failed to unlink file from content")?;
40            render_result(&result);
41            Ok(())
42        },
43        ContentFilesCommands::List(args) => {
44            let result = list::execute(args, config)
45                .await
46                .context("Failed to list content files")?;
47            render_result(&result);
48            Ok(())
49        },
50        ContentFilesCommands::Featured(args) => {
51            let result = featured::execute(args, config)
52                .await
53                .context("Failed to get/set featured image")?;
54            render_result(&result);
55            Ok(())
56        },
57    }
58}