Skip to main content

systemprompt_cli/presentation/tables/
mod.rs

1//! Reusable `tabled` table widgets for command output.
2//!
3//! Pure shaping and rendering: each function turns domain records into a
4//! rendered table string. Callers decide where the string is printed, so the
5//! row shaping stays testable without a terminal.
6//!
7//! Copyright (c) systemprompt.io — Business Source License 1.1.
8//! See <https://systemprompt.io> for licensing details.
9
10mod entities;
11mod trace;
12
13pub use self::entities::{artifact_list_table, context_list_table, db_tables_table};
14pub use self::trace::{
15    ai_requests_table, execution_steps_table, extract_latency_from_metadata, format_metadata_value,
16    mcp_tool_calls_table, task_artifacts_table, task_info_table, trace_events_table,
17};
18
19use crate::shared::truncate_with_ellipsis;
20
21#[must_use]
22pub fn truncate_cell(s: &str, max_len: usize) -> String {
23    let flattened = s.replace('\n', " ").replace('\r', "");
24    truncate_with_ellipsis(&flattened, max_len)
25}
26
27pub(super) fn dash() -> String {
28    "-".to_owned()
29}
30
31pub(super) fn millis(value: Option<impl std::fmt::Display>) -> String {
32    value.map_or_else(dash, |ms| format!("{ms}ms"))
33}