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#![allow(clippy::missing_errors_doc)]
16
17/// Fluent typed CLI lifecycle.
18#[cfg(feature = "app")]
19pub mod app;
20/// Color policy (`auto` / `always` / `never`).
21pub mod color;
22/// Semantic human presentation independent of a terminal engine.
23#[cfg(feature = "document")]
24pub mod document;
25/// Output representation (`pretty` / `json`).
26pub mod format;
27/// Schema-first wire types.
28pub mod model;
29
30/// Clap flatten structs for shared flags.
31#[cfg(feature = "cli")]
32pub mod flags;
33/// Styled `-h` / `--help` renderer.
34#[cfg(feature = "help")]
35pub mod help;
36/// Declared input: read, parse, validate once, and place every problem.
37#[cfg(feature = "input")]
38pub mod input;
39#[cfg(feature = "render")]
40mod layout;
41/// Parser defaults (`-h` / `-V` stay on).
42#[cfg(feature = "cli")]
43pub mod parser;
44/// One-import surface for a *ctl binary (`use ctl_core::prelude::*`).
45pub mod prelude;
46/// Semantic document renderer.
47#[cfg(feature = "render")]
48pub mod render;
49#[cfg(feature = "render")]
50mod style;
51/// Shared Clap-derived operator metadata and optional Jinja fragments.
52#[cfg(feature = "surface-model")]
53pub mod surface;
54/// Compact pretty tables for command output.
55#[cfg(feature = "render")]
56pub mod table;
57/// Mise Usage spec from a clap command.
58#[cfg(feature = "usage")]
59pub mod usage;
60/// Garde rules every declared schema shares.
61#[cfg(feature = "validate")]
62pub mod validate;
63/// Pretty / JSON / colorless emitters.
64#[cfg(feature = "view")]
65pub mod view;
66
67#[cfg(feature = "app")]
68pub use app::App;
69pub use color::ColorMode;
70#[cfg(feature = "document")]
71pub use document::{
72    Block, Document, Fields, Notice, NoticeLevel, Role, Rule, Section, Span, Table, Text,
73};
74#[cfg(feature = "cli")]
75pub use flags::{
76    ColorLong, DryRunArgs, FlagWarning, FormatArgs, FormatLong, OutputArgs, WarningKind,
77    chassis_warnings, emit_warnings, resolve_color, switch, warn_opposites,
78};
79pub use format::OutputFormat;
80pub use indoc::{concatdoc, eprintdoc, formatdoc, indoc, printdoc, writedoc};
81pub use model::{Envelope, ErrorBody, SCHEMA_VERSION};
82#[cfg(feature = "render")]
83pub use render::{
84    DEFAULT_COLUMN_BUFFER, DEFAULT_COLUMN_BUFFER_ENV, DEFAULT_COLUMN_BUFFER_ENVS,
85    DEFAULT_FALLBACK_WIDTH, DEFAULT_LIST_STYLE_ENV, DEFAULT_LIST_STYLE_ENVS,
86    DEFAULT_MINIMUM_AUTOMATIC_WIDTH, DEFAULT_RECORD_STYLE_ENV, DEFAULT_RECORD_STYLE_ENVS,
87    DEFAULT_ROW_SEPARATION_ENV, DEFAULT_ROW_SEPARATION_ENVS, ListStyle, RecordStyle, RenderOptions,
88    Renderer, RowSeparation,
89};
90#[cfg(feature = "surface-model")]
91pub use surface::{Surface, SurfaceArgument, SurfaceCommand, SurfaceRequirement, SurfaceScope};
92#[cfg(feature = "render")]
93pub use table::{grid, kv};
94#[cfg(feature = "usage")]
95pub use usage::{mount_line, spec, spec_bin, take};
96#[cfg(feature = "view")]
97pub use view::{
98    Captured, DEFAULT_JSON_LAYOUT_ENV, DEFAULT_JSON_LAYOUT_ENVS, JsonLayout, MessageKind, Present,
99    Stream, View,
100};