Skip to main content

osp_cli/
lib.rs

1//! `osp-cli` exists to keep the canonical `osp` product surface in one crate.
2//!
3//! The point of this crate is not just packaging. It is the place where the
4//! product's main concerns meet: CLI host orchestration, layered config
5//! resolution, rendering, REPL integration, completion, plugins, and the
6//! pipeline DSL. Keeping those boundaries visible in one crate makes rustdoc a
7//! real architecture map instead of a thin wrapper over several mirrored
8//! packages.
9//!
10//! Start here depending on what you need:
11//!
12//! - [`app`] exists to turn the lower-level pieces into a running CLI or REPL
13//!   process.
14//! - [`cli`] exists to model the public command-line grammar.
15//! - [`config`] exists to answer what values are legal, where they came from,
16//!   and what finally wins.
17//! - [`completion`] exists to rank suggestions without depending on terminal
18//!   state or editor code.
19//! - [`repl`] exists to own the interactive shell boundary.
20//! - [`dsl`] exists to provide the canonical document-first pipeline language.
21//! - [`ui`] exists to lower structured output into terminal-facing text.
22//! - [`plugin`] exists to treat external command providers as part of the same
23//!   command surface.
24//! - [`services`] and [`ports`] exist for smaller embeddable integrations that
25//!   do not want the whole host stack.
26//! - [`api`] provides test-friendly fixtures and lightweight helper adapters
27//!   rather than a second full integration surface.
28//!
29//! Architecture contracts worth keeping stable:
30//!
31//! - lower-level modules should not depend on [`app`]
32//! - [`completion`] stays pure and should not start doing network, plugin
33//!   discovery, or terminal I/O
34//! - [`ui`] renders structured input but should not become a config-resolver or
35//!   service-execution layer
36//! - [`cli`] describes the grammar of the program but does not execute it
37//! - [`config`] owns precedence and legality rules so callers do not invent
38//!   their own merge semantics
39//!
40//! Public API shape:
41//!
42//! - semantic payload modules such as [`guide`] and most of [`completion`]
43//!   stay intentionally cheap to compose and inspect
44//! - host machinery such as [`app::App`], [`app::AppBuilder`], and runtime
45//!   state is guided through constructors/builders/accessors rather than
46//!   compatibility shims or open-ended assembly
47//! - each public concept should have one canonical home; duplicate aliases and
48//!   mirrored module paths are treated as API debt
49//!
50//! Guided construction naming:
51//!
52//! - `Type::new(...)` is the exact constructor when the caller already knows
53//!   the required inputs
54//! - `Type::builder(...)` starts guided construction for heavier host/runtime
55//!   objects and returns a concrete `TypeBuilder`
56//! - builder setters use `with_*` and the terminal step is always `build()`
57//! - `Type::from_*` and `Type::detect()` are reserved for derived/probing
58//!   factories
59//! - semantic DSLs may keep domain verbs such as `arg`, `flag`, or
60//!   `subcommand`; the `with_*` rule is for guided host configuration, not for
61//!   every fluent API
62//! - avoid abstract "factory builder" layers in the public API; callers should
63//!   see concrete type-named builders and factories directly
64//!
65//! For embedders:
66//!
67//! - use [`app::App`] or [`app::AppBuilder`] for the full CLI/REPL host
68//! - use [`app::AppState::builder`] when you need a manual runtime/session
69//!   snapshot
70//! - use [`app::UiState::builder`] and [`app::LaunchContext::builder`] for the
71//!   heavier host-building blocks
72//! - use [`repl::ReplRunConfig::builder`] and [`repl::HistoryConfig::builder`]
73//!   when embedding the REPL editor surface directly
74//! - use [`guide::GuideView`] and [`completion::CompletionTreeBuilder`] for
75//!   semantic payload generation
76//! - use [`services`] and [`ports`] when you want narrower integrations instead
77//!   of the whole host stack
78//!
79//! The root crate module tree is the only supported code path. Older mirrored
80//! layouts have been removed so rustdoc and the source tree describe the same
81//! architecture.
82
83/// Test-friendly API adapters and mock implementations.
84pub mod api;
85/// Main host-facing entrypoints, runtime state, and session types.
86pub mod app;
87/// Command-line argument types and CLI parsing helpers.
88pub mod cli;
89/// Structured command and pipe completion types.
90pub mod completion;
91/// Layered configuration schema, loading, and resolution.
92pub mod config;
93/// Shared command, output, row, and protocol primitives.
94pub mod core;
95/// Canonical pipeline parsing and execution.
96pub mod dsl;
97mod dsl2;
98/// Structured help/guide view models and conversions.
99pub mod guide;
100/// External plugin discovery, protocol, and dispatch support.
101pub mod plugin;
102/// Service-layer ports used by command execution.
103pub mod ports;
104pub mod repl;
105/// Library-level service entrypoints built on the core ports.
106pub mod services;
107/// Rendering, theming, and structured output helpers.
108pub mod ui;
109
110pub use crate::app::{App, AppBuilder, AppRunner, run_from, run_process};
111pub use crate::core::command_policy;
112pub use crate::native::{
113    NativeCommand, NativeCommandCatalogEntry, NativeCommandContext, NativeCommandOutcome,
114    NativeCommandRegistry,
115};
116
117mod native;
118
119#[cfg(test)]
120mod tests;