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/// Temporary file trees for integration tests.
34#[cfg(feature = "fixture")]
35pub mod fixture;
36/// Clap flatten structs for shared flags.
37#[cfg(feature = "cli")]
38pub mod flags;
39/// Styled `-h` / `--help` renderer.
40#[cfg(feature = "help")]
41pub mod help;
42/// Declared input: read, parse, validate once, and place every problem.
43#[cfg(feature = "input")]
44pub mod input;
45#[cfg(feature = "render")]
46mod layout;
47/// Parser defaults (`-h` / `-V` stay on).
48#[cfg(feature = "cli")]
49pub mod parser;
50/// One-import surface for a *ctl binary (`use ctl_core::prelude::*`).
51pub mod prelude;
52/// Semantic document renderer.
53#[cfg(feature = "render")]
54pub mod render;
55/// Files a repository serves, rendered from templates that declare where
56/// they go.
57#[cfg(feature = "served")]
58pub mod served;
59#[cfg(feature = "render")]
60mod style;
61/// Shared Clap-derived operator metadata and optional Jinja fragments.
62#[cfg(feature = "surface-model")]
63pub mod surface;
64/// Compact pretty tables for command output.
65#[cfg(feature = "render")]
66pub mod table;
67/// Mise Usage spec from a clap command.
68#[cfg(feature = "usage")]
69pub mod usage;
70/// Garde rules every declared schema shares.
71#[cfg(feature = "validate")]
72pub mod validate;
73/// Pretty / JSON / colorless emitters.
74#[cfg(feature = "view")]
75pub mod view;
76
77#[cfg(feature = "app")]
78pub use app::App;
79pub use color::ColorMode;
80#[cfg(feature = "document")]
81pub use document::{
82    Block, Document, Fields, Notice, NoticeLevel, Role, Rule, Section, Span, Table, Text,
83};
84#[cfg(feature = "cli")]
85pub use flags::{
86    ColorLong, DryRunArgs, FlagWarning, FormatArgs, FormatLong, OutputArgs, WarningKind,
87    chassis_warnings, emit_warnings, resolve_color, switch, warn_opposites,
88};
89pub use format::OutputFormat;
90pub use indoc::{concatdoc, eprintdoc, formatdoc, indoc, printdoc, writedoc};
91pub use model::{Envelope, ErrorBody, SCHEMA_VERSION};
92#[cfg(feature = "render")]
93pub use render::{
94    DEFAULT_COLUMN_BUFFER, DEFAULT_COLUMN_BUFFER_ENV, DEFAULT_COLUMN_BUFFER_ENVS,
95    DEFAULT_FALLBACK_WIDTH, DEFAULT_LIST_STYLE_ENV, DEFAULT_LIST_STYLE_ENVS,
96    DEFAULT_MINIMUM_AUTOMATIC_WIDTH, DEFAULT_RECORD_STYLE_ENV, DEFAULT_RECORD_STYLE_ENVS,
97    DEFAULT_ROW_SEPARATION_ENV, DEFAULT_ROW_SEPARATION_ENVS, ListStyle, RecordStyle, RenderOptions,
98    Renderer, RowSeparation,
99};
100#[cfg(feature = "surface-model")]
101pub use surface::{Surface, SurfaceArgument, SurfaceCommand, SurfaceRequirement, SurfaceScope};
102#[cfg(feature = "render")]
103pub use table::{grid, kv};
104#[cfg(feature = "usage")]
105pub use usage::{mount_line, spec, spec_bin, take};
106#[cfg(feature = "view")]
107pub use view::{
108    Captured, DEFAULT_JSON_LAYOUT_ENV, DEFAULT_JSON_LAYOUT_ENVS, JsonLayout, MessageKind, Present,
109    Stream, View,
110};