1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//! SQLModel Console - Beautiful terminal output for SQLModel Rust.
//!
//! `sqlmodel-console` is the **optional UX layer** for SQLModel Rust. It renders
//! errors, query results, schema trees, and progress in a way that adapts to
//! humans (rich formatting) or agents/CI (plain or JSON).
//!
//! # Role In The Architecture
//!
//! - **Optional integration**: enabled via the `console` feature in `sqlmodel` or
//! in driver crates.
//! - **Agent-safe output**: auto-detects AI coding tools and switches to plain text.
//! - **Diagnostics**: provides structured renderables for tables, errors, and status.
//!
//! This crate provides styled console output that automatically adapts to
//! the terminal environment. When running under an AI coding agent, output
//! is plain text. When running interactively, output is richly formatted.
//!
//! # Features
//!
//! - `rich` - Enable rich formatted output with colors, tables, panels
//! - `syntax` - Enable SQL syntax highlighting (requires `rich`)
//! - `full` - Enable all features
//!
//! # Output Mode Detection
//!
//! The crate automatically detects the appropriate output mode:
//!
//! - **Plain**: AI agents (Claude Code, Codex, etc.), CI systems, piped output
//! - **Rich**: Interactive human terminal sessions
//! - **Json**: Structured output for tool integrations
//!
//! You can override detection via environment variables:
//!
//! - `SQLMODEL_PLAIN=1` - Force plain text output
//! - `SQLMODEL_RICH=1` - Force rich output (even for agents)
//! - `SQLMODEL_JSON=1` - Force JSON structured output
//!
//! # Example
//!
//! ```rust
//! use sqlmodel_console::OutputMode;
//!
//! let mode = OutputMode::detect();
//! if mode.supports_ansi() {
//! println!("Rich formatting available!");
//! } else {
//! println!("Plain text mode");
//! }
//! ```
// Forbid unsafe code in production, but allow in tests for env manipulation
// Re-export primary types
pub use SqlModelConsole;
pub use OutputMode;
pub use Theme;
pub use ConsoleAware;
/// Prelude for convenient imports.