systemprompt_cli/shared/
mod.rs1pub mod command_result;
2pub mod docker;
3pub mod parsers;
4pub mod paths;
5pub mod process;
6pub mod profile;
7pub mod project;
8pub mod text;
9
10pub use command_result::{
11 ArtifactType, ChartType, CommandResult, KeyValueItem, KeyValueOutput, RenderingHints,
12 SuccessOutput, TableOutput, TextOutput, render_result,
13};
14pub use parsers::{parse_email, parse_profile_name};
15pub use profile::{
16 ProfileResolutionError, is_path_input, resolve_profile_from_path, resolve_profile_path,
17 resolve_profile_with_data,
18};
19pub use text::truncate_with_ellipsis;
20
21#[macro_export]
22macro_rules! define_pool_command {
23 ($args_ty:ty => $ret_ty:ty, with_config) => {
24 pub async fn execute(
25 args: $args_ty,
26 config: &$crate::CliConfig,
27 ) -> ::anyhow::Result<$ret_ty> {
28 let ctx = ::systemprompt_runtime::AppContext::new().await?;
29 let pool = ctx.db_pool().pool_arc()?;
30 execute_with_pool_inner(args, &pool, config).await
31 }
32
33 pub async fn execute_with_pool(
34 args: $args_ty,
35 db_ctx: &::systemprompt_runtime::DatabaseContext,
36 config: &$crate::CliConfig,
37 ) -> ::anyhow::Result<$ret_ty> {
38 let pool = db_ctx.db_pool().pool_arc()?;
39 execute_with_pool_inner(args, &pool, config).await
40 }
41 };
42 ($args_ty:ty => $ret_ty:ty, no_config) => {
43 pub async fn execute(
44 args: $args_ty,
45 _config: &$crate::CliConfig,
46 ) -> ::anyhow::Result<$ret_ty> {
47 let ctx = ::systemprompt_runtime::AppContext::new().await?;
48 let pool = ctx.db_pool().pool_arc()?;
49 execute_with_pool_inner(args, &pool).await
50 }
51
52 pub async fn execute_with_pool(
53 args: $args_ty,
54 db_ctx: &::systemprompt_runtime::DatabaseContext,
55 _config: &$crate::CliConfig,
56 ) -> ::anyhow::Result<$ret_ty> {
57 let pool = db_ctx.db_pool().pool_arc()?;
58 execute_with_pool_inner(args, &pool).await
59 }
60 };
61}