// REGION: API // api: binary::main() -> (process exit) // api: binary::real_main() -> zosstorage::Result<()> // REGION: API-END // // REGION: RESPONSIBILITIES // - Minimal binary wrapper: parse CLI, init logging, load+validate config, run orchestrator. // - Emit minimal fatal errors to stderr only; no stdout spam. // Non-goals: business logic, module orchestration details (delegated to orchestrator). // REGION: RESPONSIBILITIES-END // // REGION: EXTENSION_POINTS // ext: add --version/--help output via clap (already provided by clap derive). // ext: add build-info banner to logs when debug level (feature-gated). // REGION: EXTENSION_POINTS-END // // REGION: SAFETY // safety: never print secrets; errors are concise. Avoids panics; returns proper exit codes. // REGION: SAFETY-END // // REGION: ERROR_MAPPING // errmap: any failure bubbles as crate::Error via real_main() and is printed as a single-line stderr. // REGION: ERROR_MAPPING-END // // REGION: TODO // todo: add tracing spans around boot phases once logging init is implemented. // REGION: TODO-END //! Binary entrypoint for zosstorage. //! //! Initializes logging, parses CLI, loads/validates configuration, //! and invokes the orchestrator run sequence. Avoids stdout spam. use zosstorage::{Result, cli, config, logging, orchestrator}; fn main() { if let Err(e) = real_main() { // Minimal stderr emission permitted for fatal errors in initramfs. eprintln!("error: {e}"); std::process::exit(1); } } /// Orchestrates initialization steps and runs the provisioning flow. fn real_main() -> Result<()> { let cli = cli::from_args(); let log_opts = logging::LogOptions::from_cli(&cli); logging::init_logging(&log_opts)?; let cfg = config::load_and_merge(&cli)?; config::validate(&cfg)?; let ctx = orchestrator::Context::new(cfg, log_opts) .with_show(cli.show) .with_apply(cli.apply) .with_mount_existing(cli.mount_existing) .with_report_current(cli.report_current) .with_report_path(cli.report.clone()) .with_topology_from_cli(cli.topology.is_some()) .with_topology_from_cmdline( config::loader::kernel_cmdline_topology().is_some() && cli.topology.is_none(), ); orchestrator::run(&ctx) }