Skip to main content

systemprompt_cli/shared/
mod.rs

1//! Cross-command CLI utilities shared across command modules.
2//!
3//! Aggregates the [`CommandOutput`] artifact model and its output types,
4//! profile resolution ([`resolve_profile_path`],
5//! [`resolve_profile_with_data`]), argument parsers, and text helpers. Also
6//! defines the `define_pool_command!` macro used by the log commands to
7//! generate pooled execution entry points.
8
9pub mod command_result;
10pub mod parsers;
11pub mod paths;
12pub mod profile;
13pub mod project;
14pub mod text;
15
16pub use command_result::{
17    ChartType, CommandOutput, KeyValueItem, KeyValueOutput, SuccessOutput, TableOutput, TextOutput,
18    render_result,
19};
20pub use parsers::{parse_email, parse_profile_name};
21pub use profile::{
22    ProfileResolutionError, is_path_input, resolve_profile_from_path, resolve_profile_path,
23    resolve_profile_with_data,
24};
25pub use text::truncate_with_ellipsis;
26
27#[macro_export]
28macro_rules! define_pool_command {
29    ($args_ty:ty => $ret_ty:ty, with_config) => {
30        pub(in $crate::commands::infrastructure::logs) async fn execute(
31            args: $args_ty,
32            ctx: &$crate::context::CommandContext,
33        ) -> ::anyhow::Result<$ret_ty> {
34            let pool = ctx.db_pool().await?.pool_arc()?;
35            execute_with_pool_inner(args, &pool, &ctx.cli).await
36        }
37    };
38    ($args_ty:ty => $ret_ty:ty, no_config) => {
39        pub(in $crate::commands::infrastructure::logs) async fn execute(
40            args: $args_ty,
41            ctx: &$crate::context::CommandContext,
42        ) -> ::anyhow::Result<$ret_ty> {
43            let pool = ctx.db_pool().await?.pool_arc()?;
44            execute_with_pool_inner(args, &pool).await
45        }
46    };
47}