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