// SPDX-License-Identifier: Prosperity-3.0.0 // Copyright Scienting // Source: https://git.scient.ing/education/coursebank //! The `coursebank` command-line interface. //! //! Command names follow the workflow rather than the data model: you `assemble` an //! exam, `ingest` the grading export, `analyze` it, and `report`. Every command that //! modifies a bank prints what it would change and requires `--apply` to do it, //! because these files are reviewed artifacts in a git repository and a silent //! rewrite is not something you want to discover in a diff later. //! //! Exit codes are meaningful for scripting and CI: `0` for success, `1` for a //! failure, `2` when validation or linting found problems. That last one is the //! reason a course repository can have a pre-commit hook. //! //! # Module layout //! //! `main.rs` is deliberately thin. The pieces live in sibling modules: //! //! - [`cli`] — the `clap` argument model (every flag, subcommand, and the small //! conversions from CLI-facing enums into the library's domain enums). //! - [`commands`] — the [`run`](commands::run) dispatcher plus one submodule per //! workflow stage, each holding the handlers for its subcommands. //! - [`helpers`] — shared plumbing used by more than one handler: loading the //! catalog, resolving records and forms, parsing `KEY=VALUE` flags, and the //! text formatting used by the various listings. //! - [`import`] — the one-off legacy-JSON importer, kept apart because it is large //! and touched rarely. mod cli; mod commands; mod helpers; use std::process::ExitCode; use clap::Parser; use crate::cli::Cli; use crate::commands::{Outcome, run}; /// Parses the command line, runs the requested command, and maps its result onto /// a process exit code. /// /// See the crate-level documentation for the meaning of each code. fn main() -> ExitCode { let cli = Cli::parse(); match run(&cli) { Ok(Outcome::Ok) => ExitCode::SUCCESS, Ok(Outcome::Findings) => ExitCode::from(2), Err(e) => { eprintln!("error: {e}"); ExitCode::FAILURE } } }