76 lines
2.7 KiB
Rust
76 lines
2.7 KiB
Rust
// SPDX-License-Identifier: Prosperity-3.0.0
|
|
// Copyright Scientific Computing Studio
|
|
// Source: https://git.scient.ing/education/coursebank
|
|
|
|
//! Command handlers, grouped by workflow stage.
|
|
//!
|
|
//! [`run`] is the single dispatch point: it matches the parsed [`Command`] and
|
|
//! calls the matching handler. The handlers themselves live in submodules that
|
|
//! follow the workflow described in the crate documentation:
|
|
//!
|
|
//! - [`project`] — set up and check a course: `init`, `schema`, `validate`,
|
|
//! `lint`, `catalog`.
|
|
//! - [`lectures`] — render a lecture's reading list and check what backs each
|
|
//! objective: `lecture`.
|
|
//! - [`banks`] — manage items and build assessments: `bank`, `assessment`,
|
|
//! `assemble`, `usage`.
|
|
//! - [`export`] — turn an assessment into deliverables: `export`, `template`.
|
|
//! - [`analysis`] — the responses-to-report pipeline: `ingest`, `analyze`,
|
|
//! `calibrate`, `report`, `data`.
|
|
//!
|
|
//! Every handler returns [`Outcome`] so the dispatcher can distinguish "finished
|
|
//! cleanly" from "finished, but found problems worth a non-zero exit code".
|
|
|
|
pub(crate) mod analysis;
|
|
pub(crate) mod banks;
|
|
pub(crate) mod export;
|
|
pub(crate) mod lectures;
|
|
pub(crate) mod project;
|
|
|
|
use coursebank::error::Result;
|
|
|
|
use crate::cli::{Cli, Command};
|
|
|
|
/// What a command concluded.
|
|
pub(crate) enum Outcome {
|
|
/// Nothing to report.
|
|
Ok,
|
|
/// Problems were found, which is not the same as the command failing.
|
|
Findings,
|
|
}
|
|
|
|
/// Dispatches a command.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `cli` - the parsed arguments.
|
|
///
|
|
/// # Returns
|
|
///
|
|
/// Whether findings were reported.
|
|
///
|
|
/// # Errors
|
|
///
|
|
/// Propagates any failure from the underlying operation.
|
|
pub(crate) fn run(cli: &Cli) -> Result<Outcome> {
|
|
match &cli.command {
|
|
Command::Init(args) => project::init(cli, args),
|
|
Command::Schema => project::schema(cli),
|
|
Command::Validate => project::validate(cli),
|
|
Command::Lint(args) => project::lint(cli, args),
|
|
Command::Catalog(args) => project::catalog(cli, args),
|
|
Command::Lecture(sub) => lectures::lecture(cli, sub),
|
|
Command::Bank(sub) => banks::bank(cli, sub),
|
|
Command::Assessment(sub) => banks::assessment(cli, sub),
|
|
Command::Assemble(args) => banks::assemble(cli, args),
|
|
Command::Usage(sub) => banks::usage(cli, sub),
|
|
Command::Export(sub) => export::export(cli, sub),
|
|
Command::Template(sub) => export::template(cli, sub),
|
|
Command::Ingest(sub) => analysis::ingest(cli, sub),
|
|
Command::Analyze(sub) => analysis::analyze(cli, sub),
|
|
Command::Calibrate(args) => analysis::calibrate(cli, args),
|
|
Command::Report(sub) => analysis::report(cli, sub),
|
|
Command::Data => analysis::data(cli),
|
|
}
|
|
}
|