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::{
26 parse_agent_name, parse_ai_request_id, parse_api_key_id, parse_campaign_id, parse_category_id,
27 parse_email, parse_extension_id, parse_job_name, parse_link_click_id, parse_link_id,
28 parse_mcp_server_id, parse_mcp_tool_name, parse_model_id, parse_plugin_id, parse_profile_name,
29 parse_profile_name_arg, parse_provider_id, parse_secret_name, parse_service_name,
30 parse_skill_id, parse_tenant_id, parse_trace_id,
31};
32pub use profile::{
33 ProfileResolutionError, ProfileSource, ResolvedProfile, is_path_input,
34 resolve_profile_from_path, resolve_profile_path, resolve_profile_with_data,
35};
36pub use text::truncate_with_ellipsis;
37
38#[must_use]
39pub fn database_scoped_command_error() -> anyhow::Error {
40 systemprompt_config::ProfileBootstrap::get().map_or_else(
41 |_| {
42 anyhow::anyhow!(
43 "This command requires full profile context.\nPass --profile <local-profile> to \
44 target a local environment, or re-authenticate with 'systemprompt admin session \
45 login'."
46 )
47 },
48 |profile| {
49 anyhow::anyhow!(
50 "Active profile '{}' routes to an external/cloud database, which this command does \
51 not support.\nPass --profile <local-profile> to target a local environment, or \
52 re-authenticate with 'systemprompt admin session login'.",
53 profile.name
54 )
55 },
56 )
57}
58
59#[macro_export]
60macro_rules! define_pool_command {
61 ($args_ty:ty => $ret_ty:ty, with_config) => {
62 pub(in $crate::commands::infrastructure::logs) async fn execute(
63 args: $args_ty,
64 ctx: &$crate::context::CommandContext,
65 ) -> ::anyhow::Result<$ret_ty> {
66 let pool = ctx.db_pool().await?.pool();
67 execute_with_pool_inner(args, &pool, &ctx.cli).await
68 }
69 };
70 ($args_ty:ty => $ret_ty:ty, no_config) => {
71 pub(in $crate::commands::infrastructure::logs) async fn execute(
72 args: $args_ty,
73 ctx: &$crate::context::CommandContext,
74 ) -> ::anyhow::Result<$ret_ty> {
75 let pool = ctx.db_pool().await?.pool();
76 execute_with_pool_inner(args, &pool).await
77 }
78 };
79}