Skip to main content

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

1//! `core files ai` command group: inspect AI-generated image files.
2//!
3//! Dispatches the [`AiCommands`] subcommands (list, show, count) over files
4//! flagged as AI-generated content.
5//!
6//! Copyright (c) systemprompt.io — Business Source License 1.1.
7//! See <https://systemprompt.io> for licensing details.
8
9mod count;
10pub mod list;
11pub mod show;
12
13use anyhow::{Context, Result};
14use clap::Subcommand;
15
16use crate::context::CommandContext;
17use crate::shared::render_result;
18
19#[derive(Debug, Subcommand)]
20pub enum AiCommands {
21    #[command(about = "List AI-generated images")]
22    List(list::ListArgs),
23
24    #[command(about = "Show AI-generated image details")]
25    Show(show::ShowArgs),
26
27    #[command(about = "Count AI-generated images")]
28    Count(count::CountArgs),
29}
30
31pub async fn execute(cmd: AiCommands, ctx: &CommandContext) -> Result<()> {
32    let config = &ctx.cli;
33    match cmd {
34        AiCommands::List(args) => {
35            let result = list::execute(args, ctx)
36                .await
37                .context("Failed to list AI images")?;
38            render_result(&result, config);
39            Ok(())
40        },
41        AiCommands::Show(args) => {
42            let result = show::execute(args, ctx)
43                .await
44                .context("Failed to show AI image")?;
45            render_result(&result, config);
46            Ok(())
47        },
48        AiCommands::Count(args) => {
49            let result = count::execute(args, ctx)
50                .await
51                .context("Failed to count AI images")?;
52            render_result(&result, config);
53            Ok(())
54        },
55    }
56}