Skip to main content

ctl_core/
lib.rs

1//! Shared clap chassis and presentation kernel for the `*ctl` CLIs.
2//!
3//! Not a command. Import as [`ctl_core`](crate). Domain handlers return typed
4//! data. [`Document`] describes the human view, [`View`] chooses pretty,
5//! colorless, or JSON, and the terminal engine remains private to this crate.
6//!
7//! ## Cargo features
8#![doc = document_features::document_features!()]
9//!
10//! Unused features do not compile `clap`, `comfy-table`, or `schemars`.
11//!
12//! Crate docs live here. The GitHub README is not rustdoc.
13
14#![deny(missing_docs, rustdoc::broken_intra_doc_links)]
15#![expect(
16    clippy::missing_errors_doc,
17    reason = "each fallible function returns one typed error whose variants carry the docs"
18)]
19
20/// Fluent typed CLI lifecycle.
21#[cfg(feature = "app")]
22pub mod app;
23/// Color policy (`auto` / `always` / `never`).
24pub mod color;
25/// Semantic human presentation independent of a terminal engine.
26#[cfg(feature = "document")]
27pub mod document;
28/// Output representation (`pretty` / `json`).
29pub mod format;
30/// Schema-first wire types.
31pub mod model;
32
33/// The Rust configuration every ctl repository shares, served from this
34/// release.
35#[cfg(feature = "baseline")]
36pub mod baseline;
37/// Temporary file trees for integration tests.
38#[cfg(feature = "fixture")]
39pub mod fixture;
40/// Clap flatten structs for shared flags.
41#[cfg(feature = "cli")]
42pub mod flags;
43/// Styled `-h` / `--help` renderer.
44#[cfg(feature = "help")]
45pub mod help;
46/// Declared input: read, parse, validate once, and place every problem.
47#[cfg(feature = "input")]
48pub mod input;
49#[cfg(feature = "render")]
50mod layout;
51/// Parser defaults (`-h` / `-V` stay on).
52#[cfg(feature = "cli")]
53pub mod parser;
54/// One-import surface for a *ctl binary (`use ctl_core::prelude::*`).
55pub mod prelude;
56/// Semantic document renderer.
57#[cfg(feature = "render")]
58pub mod render;
59/// Files a repository serves, rendered from templates that declare where
60/// they go.
61#[cfg(feature = "served")]
62pub mod served;
63#[cfg(feature = "render")]
64mod style;
65/// Shared Clap-derived operator metadata and optional Jinja fragments.
66#[cfg(feature = "surface-model")]
67pub mod surface;
68/// Compact pretty tables for command output.
69#[cfg(feature = "render")]
70pub mod table;
71/// Mise Usage spec from a clap command.
72#[cfg(feature = "usage")]
73pub mod usage;
74/// Garde rules every declared schema shares.
75#[cfg(feature = "validate")]
76pub mod validate;
77/// Pretty / JSON / colorless emitters.
78#[cfg(feature = "view")]
79pub mod view;
80
81#[cfg(feature = "app")]
82pub use app::App;
83pub use color::ColorMode;
84#[cfg(feature = "document")]
85pub use document::{
86    Block, Document, Fields, Notice, NoticeLevel, Role, Rule, Section, Span, Table, Text,
87};
88#[cfg(feature = "cli")]
89pub use flags::{
90    ColorLong, DryRunArgs, FlagWarning, FormatArgs, FormatLong, OutputArgs, WarningKind,
91    chassis_warnings, emit_warnings, resolve_color, switch, warn_opposites,
92};
93pub use format::OutputFormat;
94pub use indoc::{concatdoc, eprintdoc, formatdoc, indoc, printdoc, writedoc};
95pub use model::{Envelope, ErrorBody, SCHEMA_VERSION};
96#[cfg(feature = "render")]
97pub use render::{
98    DEFAULT_COLUMN_BUFFER, DEFAULT_COLUMN_BUFFER_ENV, DEFAULT_COLUMN_BUFFER_ENVS,
99    DEFAULT_FALLBACK_WIDTH, DEFAULT_LIST_STYLE_ENV, DEFAULT_LIST_STYLE_ENVS,
100    DEFAULT_MINIMUM_AUTOMATIC_WIDTH, DEFAULT_RECORD_STYLE_ENV, DEFAULT_RECORD_STYLE_ENVS,
101    DEFAULT_ROW_SEPARATION_ENV, DEFAULT_ROW_SEPARATION_ENVS, ListStyle, RecordStyle, RenderOptions,
102    Renderer, RowSeparation,
103};
104#[cfg(feature = "surface-model")]
105pub use surface::{Surface, SurfaceArgument, SurfaceCommand, SurfaceRequirement, SurfaceScope};
106#[cfg(feature = "render")]
107pub use table::{grid, kv};
108#[cfg(feature = "usage")]
109pub use usage::{mount_line, spec, spec_bin, take};
110#[cfg(feature = "view")]
111pub use view::{
112    Captured, DEFAULT_JSON_LAYOUT_ENV, DEFAULT_JSON_LAYOUT_ENVS, JsonLayout, MessageKind, Present,
113    Stream, View,
114};