1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
//! locode-exec — the minimal headless CLI (Task 14, ADR-0009), as a library.
//!
//! The crate ships both a binary (the stock CLI) and this lib target so
//! downstream binary crates can reuse the *entire* CLI — flags, session
//! assembly, stdout discipline, exit codes — while injecting custom providers
//! (ADR-0015):
//!
//! ```no_run
//! use locode_exec::{ProviderRegistry, main_with};
//!
//! fn main() -> std::process::ExitCode {
//! main_with(ProviderRegistry::builtin() /* .register("my-wire", …) */)
//! }
//! ```
//!
//! Stdout discipline: stdout carries exactly one machine-readable artifact
//! (the JSON report, the final message, or the JSONL event stream — by
//! `--output-format`), enforced structurally: the workspace denies
//! `print_stdout`/`print_stderr`, and the ONLY allows live in `output.rs`
//! (Codex-exec's pattern). All diagnostics go to stderr; exit codes map the
//! run's terminal status (0 = structured, 1 = fatal, 2 = usage via clap).
use ExitCode;
use Parser;
pub use ;
pub use ProviderRegistry;
/// Parse the CLI, install logging, and drive one session to its exit code —
/// the whole binary, minus `fn main`. Custom providers come in through
/// `registry`; the stock binary passes [`ProviderRegistry::builtin`].
// By-value on purpose: the downstream `fn main` is a single expression
// (`main_with(builtin().register(…))`) with no borrow to scope.
/// Drive one headless run from an already-parsed [`Cli`] — installs logging,
/// builds the runtime, runs the engine, and emits per `--output-format`.
///
/// Split out of [`main_with`] so a unified front-end (the `locode` binary's
/// `-p` mode) can reuse the exact headless engine without re-parsing argv.
/// When `locode-exec` retires, this logic migrates into the front-end crate
/// (ADR-0019 amendment 2026-07-21).