systemprompt_cli/commands/core/content/files/
mod.rs1pub mod featured;
11pub mod link;
12pub mod list;
13pub mod unlink;
14
15use anyhow::{Context, Result};
16use clap::Subcommand;
17
18use crate::context::CommandContext;
19use crate::interactive::Prompter;
20use crate::shared::render_result;
21
22#[derive(Debug, Subcommand)]
23pub enum ContentFilesCommands {
24 #[command(about = "Link a file to content with a specific role")]
25 Link(link::LinkArgs),
26
27 #[command(about = "Unlink a file from content")]
28 Unlink(unlink::UnlinkArgs),
29
30 #[command(about = "List files attached to content")]
31 List(list::ListArgs),
32
33 #[command(about = "Get or set the featured image for content")]
34 Featured(featured::FeaturedArgs),
35}
36
37pub async fn execute(
38 cmd: ContentFilesCommands,
39 prompter: &dyn Prompter,
40 ctx: &CommandContext,
41) -> Result<()> {
42 let config = &ctx.cli;
43 match cmd {
44 ContentFilesCommands::Link(args) => {
45 let result = link::execute(args, ctx)
46 .await
47 .context("Failed to link file to content")?;
48 render_result(&result, config);
49 Ok(())
50 },
51 ContentFilesCommands::Unlink(args) => {
52 let result = unlink::execute(args, prompter, ctx)
53 .await
54 .context("Failed to unlink file from content")?;
55 render_result(&result, config);
56 Ok(())
57 },
58 ContentFilesCommands::List(args) => {
59 let result = list::execute(args, ctx)
60 .await
61 .context("Failed to list content files")?;
62 render_result(&result, config);
63 Ok(())
64 },
65 ContentFilesCommands::Featured(args) => {
66 let result = featured::execute(args, ctx)
67 .await
68 .context("Failed to get/set featured image")?;
69 render_result(&result, config);
70 Ok(())
71 },
72 }
73}