Skip to main content

ralph_workflow/cli/reducer/
mod.rs

1//! CLI argument reducer module.
2//!
3//! This module implements a reducer-based architecture for processing CLI arguments,
4//! following the same patterns as the pipeline reducer in `crate::reducer`.
5//!
6//! # Architecture
7//!
8//! ```text
9//! Args (clap) → args_to_events() → [CliEvent] → reduce() → CliState → apply_to_config() → Config
10//! ```
11//!
12//! ## Benefits
13//!
14//! - **Testable**: Pure reducer function is easy to unit test
15//! - **Maintainable**: Adding new CLI args = add event + reducer case
16//! - **Consistent**: Matches existing pipeline reducer architecture
17//! - **Traceable**: Event sequence can be logged/debugged
18//!
19//! # Example
20//!
21//! ```ignore
22//! use crate::cli::reducer::{args_to_events, reduce, CliState, apply_cli_state_to_config};
23//!
24//! let events = args_to_events(&args);
25//! let mut state = CliState::initial();
26//! for event in events {
27//!     state = reduce(state, event);
28//! }
29//! apply_cli_state_to_config(&state, &mut config);
30//! ```
31
32pub mod apply;
33pub mod event;
34pub mod parser;
35pub mod state;
36pub mod state_reduction;
37
38// Re-export key types for convenience
39pub use apply::apply_cli_state_to_config;
40pub use parser::args_to_events;
41pub use state::CliState;
42pub use state_reduction::reduce;
43
44// Public API is exposed through presets::apply_args_to_config
45// Modules are made public to allow imports from presets.rs
46// Note: Only re-export items that are actually used to avoid unused-import suppressions.