systemprompt_cli/shared/
mod.rs1pub mod command_result;
13pub mod disk_logs;
14pub mod parsers;
15pub mod profile;
16pub mod project;
17pub mod text;
18
19pub use command_result::{
20 ChartType, CommandOutput, KeyValueItem, KeyValueOutput, SuccessOutput, TableOutput, TextOutput,
21 render_result,
22};
23pub use parsers::{parse_email, parse_profile_name};
24pub use profile::{
25 ProfileResolutionError, is_path_input, resolve_profile_from_path, resolve_profile_path,
26 resolve_profile_with_data,
27};
28pub use text::truncate_with_ellipsis;
29
30#[must_use]
31pub fn database_scoped_command_error() -> anyhow::Error {
32 systemprompt_config::ProfileBootstrap::get().map_or_else(
33 |_| {
34 anyhow::anyhow!(
35 "This command requires full profile context.\nPass --profile <local-profile> to \
36 target a local environment, or re-authenticate with 'systemprompt admin session \
37 login'."
38 )
39 },
40 |profile| {
41 anyhow::anyhow!(
42 "Active profile '{}' routes to an external/cloud database, which this command does \
43 not support.\nPass --profile <local-profile> to target a local environment, or \
44 re-authenticate with 'systemprompt admin session login'.",
45 profile.name
46 )
47 },
48 )
49}
50
51#[macro_export]
52macro_rules! define_pool_command {
53 ($args_ty:ty => $ret_ty:ty, with_config) => {
54 pub(in $crate::commands::infrastructure::logs) async fn execute(
55 args: $args_ty,
56 ctx: &$crate::context::CommandContext,
57 ) -> ::anyhow::Result<$ret_ty> {
58 let pool = ctx.db_pool().await?.pool_arc()?;
59 execute_with_pool_inner(args, &pool, &ctx.cli).await
60 }
61 };
62 ($args_ty:ty => $ret_ty:ty, no_config) => {
63 pub(in $crate::commands::infrastructure::logs) async fn execute(
64 args: $args_ty,
65 ctx: &$crate::context::CommandContext,
66 ) -> ::anyhow::Result<$ret_ty> {
67 let pool = ctx.db_pool().await?.pool_arc()?;
68 execute_with_pool_inner(args, &pool).await
69 }
70 };
71}