Skip to main content

ctl_core/
lib.rs

1//! Shared clap chassis for the `*ctl` CLIs.
2//!
3//! Not a command. Import as [`ctl_core`](crate). Models
4//! ([`Envelope`], [`ColorMode`], [`OutputFormat`]) come first. [`View`]
5//! picks pretty, JSON, or colorless. JSON never contains ANSI.
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/// Color policy (`auto` / `always` / `never`).
18pub mod color;
19/// Output representation (`pretty` / `json`).
20pub mod format;
21/// Schema-first wire types.
22pub mod model;
23
24/// Clap flatten structs for shared flags.
25#[cfg(feature = "cli")]
26pub mod flags;
27/// Styled `-h` / `--help` renderer.
28#[cfg(feature = "help")]
29pub mod help;
30/// Terminal width helpers for help tables.
31#[cfg(feature = "help")]
32pub mod layout;
33/// Parser defaults (`-h` / `-V` stay on).
34#[cfg(feature = "cli")]
35pub mod parser;
36/// One-import surface for a *ctl binary (`use ctl_core::prelude::*`).
37pub mod prelude;
38/// Process `ExitCode` wrapper.
39#[cfg(feature = "cli")]
40pub mod run;
41/// ANSI styles for pretty views.
42#[cfg(feature = "color")]
43pub mod style;
44/// Compact pretty tables for command output.
45#[cfg(feature = "view")]
46pub mod table;
47/// Pretty / JSON / colorless emitters.
48#[cfg(feature = "view")]
49pub mod view;
50
51pub use color::ColorMode;
52#[cfg(feature = "cli")]
53pub use flags::{
54    ColorLong, DryRunArgs, FlagWarning, FormatArgs, OutputArgs, WarningKind, chassis_warnings,
55    emit_warnings, resolve_color, switch, warn_opposites,
56};
57pub use format::OutputFormat;
58pub use indoc::{concatdoc, eprintdoc, formatdoc, indoc, printdoc, writedoc};
59pub use model::{Envelope, ErrorBody, SCHEMA_VERSION};
60#[cfg(feature = "cli")]
61pub use run::main as run;
62#[cfg(feature = "view")]
63pub use table::{grid, kv};
64#[cfg(feature = "view")]
65pub use view::{Pretty, Render, View, render_template};