Skip to main content

systemprompt_cli/commands/core/artifacts/
mod.rs

1//! `core artifacts` command group: inspect A2A task artifacts.
2//!
3//! Dispatches the [`ArtifactsCommands`] subcommands (list, show) against either
4//! a freshly bootstrapped [`AppContext`](systemprompt_runtime::AppContext) or a
5//! supplied [`DbPool`], rendering each command's `CommandOutput` to the
6//! configured output sink.
7
8mod list;
9mod show;
10mod types;
11
12use crate::cli_settings::CliConfig;
13use crate::shared::render_result;
14use anyhow::Result;
15use clap::Subcommand;
16use systemprompt_database::DbPool;
17
18pub use types::*;
19
20#[derive(Debug, Subcommand)]
21pub enum ArtifactsCommands {
22    #[command(about = "List artifacts")]
23    List(list::ListArgs),
24
25    #[command(about = "Show artifact details and content")]
26    Show(show::ShowArgs),
27}
28
29pub async fn execute(cmd: ArtifactsCommands, config: &CliConfig) -> Result<()> {
30    match cmd {
31        ArtifactsCommands::List(args) => {
32            let result = list::execute(args, config).await?;
33            render_result(&result);
34        },
35        ArtifactsCommands::Show(args) => {
36            let result = show::execute(args, config).await?;
37            render_result(&result);
38        },
39    }
40    Ok(())
41}
42
43pub async fn execute_with_db(
44    cmd: ArtifactsCommands,
45    db_pool: &DbPool,
46    user_id: &systemprompt_identifiers::UserId,
47    config: &CliConfig,
48) -> Result<()> {
49    match cmd {
50        ArtifactsCommands::List(args) => {
51            let result = list::execute_with_pool(args, user_id, db_pool, config).await?;
52            render_result(&result);
53        },
54        ArtifactsCommands::Show(args) => {
55            let result = show::execute_with_pool(args, db_pool, config).await?;
56            render_result(&result);
57        },
58    }
59    Ok(())
60}