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#[cfg(feature = "render")]
37mod layout;
38/// Parser defaults (`-h` / `-V` stay on).
39#[cfg(feature = "cli")]
40pub mod parser;
41/// One-import surface for a *ctl binary (`use ctl_core::prelude::*`).
42pub mod prelude;
43/// Semantic document renderer.
44#[cfg(feature = "render")]
45pub mod render;
46/// Process `ExitCode` wrapper.
47#[cfg(feature = "cli")]
48pub mod run;
49#[cfg(feature = "render")]
50mod style;
51/// Compact pretty tables for command output.
52#[cfg(feature = "render")]
53pub mod table;
54/// Mise Usage spec from a clap command.
55#[cfg(feature = "usage")]
56pub mod usage;
57/// Pretty / JSON / colorless emitters.
58#[cfg(feature = "view")]
59pub mod view;
60
61#[cfg(feature = "app")]
62pub use app::App;
63pub use color::ColorMode;
64#[cfg(feature = "document")]
65pub use document::{
66    Block, Document, Fields, Notice, NoticeLevel, Role, Rule, Section, Span, Table, Text,
67};
68#[cfg(feature = "cli")]
69pub use flags::{
70    ColorLong, DryRunArgs, FlagWarning, FormatArgs, FormatLong, OutputArgs, WarningKind,
71    chassis_warnings, emit_warnings, resolve_color, switch, warn_opposites,
72};
73pub use format::OutputFormat;
74pub use indoc::{concatdoc, eprintdoc, formatdoc, indoc, printdoc, writedoc};
75pub use model::{Envelope, ErrorBody, SCHEMA_VERSION};
76#[cfg(feature = "render")]
77pub use render::{RenderOptions, Renderer};
78#[cfg(feature = "cli")]
79pub use run::main as run;
80#[cfg(feature = "render")]
81pub use table::{grid, kv};
82#[cfg(feature = "usage")]
83pub use usage::{mount_line, spec, spec_bin, take};
84#[cfg(feature = "view")]
85pub use view::{Captured, MessageKind, Present, Stream, View};