systemprompt_cli/shared/
mod.rs1pub 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#[must_use]
28pub fn database_scoped_command_error() -> anyhow::Error {
29 systemprompt_config::ProfileBootstrap::get().map_or_else(
30 |_| {
31 anyhow::anyhow!(
32 "This command requires full profile context.\nPass --profile <local-profile> to \
33 target a local environment, or re-authenticate with 'systemprompt admin session \
34 login'."
35 )
36 },
37 |profile| {
38 anyhow::anyhow!(
39 "Active profile '{}' routes to an external/cloud database, which this command does \
40 not support.\nPass --profile <local-profile> to target a local environment, or \
41 re-authenticate with 'systemprompt admin session login'.",
42 profile.name
43 )
44 },
45 )
46}
47
48#[macro_export]
49macro_rules! define_pool_command {
50 ($args_ty:ty => $ret_ty:ty, with_config) => {
51 pub(in $crate::commands::infrastructure::logs) async fn execute(
52 args: $args_ty,
53 ctx: &$crate::context::CommandContext,
54 ) -> ::anyhow::Result<$ret_ty> {
55 let pool = ctx.db_pool().await?.pool_arc()?;
56 execute_with_pool_inner(args, &pool, &ctx.cli).await
57 }
58 };
59 ($args_ty:ty => $ret_ty:ty, no_config) => {
60 pub(in $crate::commands::infrastructure::logs) async fn execute(
61 args: $args_ty,
62 ctx: &$crate::context::CommandContext,
63 ) -> ::anyhow::Result<$ret_ty> {
64 let pool = ctx.db_pool().await?.pool_arc()?;
65 execute_with_pool_inner(args, &pool).await
66 }
67 };
68}