Skip to main content

cirious_codex_cli/
lib.rs

1//! # Cirious Codex CLI
2//!
3//! The premier entrypoint library for building powerful, production-ready Command
4//! Line Interfaces (CLIs) and microservices within the Cirious ecosystem.
5//!
6//! This crate automates the entire bootstrapping process. Instead of writing
7//! boilerplate code to parse arguments, instantiate loggers, and load environment
8//! configurations, `cirious_codex_cli` handles it seamlessly. It orchestrates
9//! `cirious_codex_config` and `cirious_codex_logger` out of the box, allowing
10//! developers to focus purely on business logic.
11//!
12//! ## Quick Start
13//!
14//! Define your CLI structure using `clap` and embed `GlobalArgs`. Then,
15//! implement the `CodexCommand` trait and use `execute_cli` to bootstrap
16//! the ecosystem and route your commands.
17//!
18//! ```no_run
19//! use cirious_codex_cli::{execute_cli, CodexCommand, GlobalArgs};
20//! use clap::{Parser, Subcommand};
21//!
22//! #[derive(Parser, Debug)]
23//! #[command(name = "my_microservice")]
24//! struct AppCLI {
25//!     #[command(flatten)]
26//!     global: GlobalArgs,
27//!
28//!     #[command(subcommand)]
29//!     command: Commands,
30//! }
31//!
32//! #[derive(Subcommand, Debug)]
33//! enum Commands {
34//!     Start { port: u16 },
35//!     Ping,
36//! }
37//!
38//! impl CodexCommand for AppCLI {
39//!     fn global_args(&self) -> &GlobalArgs {
40//!         &self.global
41//!     }
42//! }
43//!
44//! fn main() {
45//!     execute_cli::<AppCLI, _>(|parsed_cli| match parsed_cli.command {
46//!         Commands::Start { port } => println!("Starting server on port {}", port),
47//!         Commands::Ping => println!("Pong!"),
48//!     });
49//! }
50//! ```
51
52#![warn(missing_docs)]
53
54/// Core argument parsing and command routing definitions.
55///
56/// This module provides the essential structures and traits needed to intercept
57/// global flags and bootstrap the application.
58pub mod args;
59
60#[cfg(feature = "config")]
61pub use args::execute_cli_with_config;
62
63pub use args::{execute_cli, CodexCommand, GlobalArgs};