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