Skip to main content

lintel_check/
lib.rs

1#![doc = include_str!("../README.md")]
2
3use anyhow::Result;
4use bpaf::Bpaf;
5pub use lintel_validate::Reporter;
6
7// -----------------------------------------------------------------------
8// CheckArgs — CLI struct for the `lintel check` command
9// -----------------------------------------------------------------------
10
11#[derive(Debug, Clone, Bpaf)]
12#[bpaf(generate(check_args_inner))]
13pub struct CheckArgs {
14    #[bpaf(external(lintel_validate::validate_args))]
15    pub validate: lintel_validate::ValidateArgs,
16}
17
18/// Construct the bpaf parser for `CheckArgs`.
19pub fn check_args() -> impl bpaf::Parser<CheckArgs> {
20    check_args_inner()
21}
22
23/// Run all checks: schema validation (and formatting in the future).
24///
25/// Returns `Ok(true)` if any errors were found, `Ok(false)` if clean.
26///
27/// # Errors
28///
29/// Returns an error if schema validation fails to run (e.g. network or I/O issues).
30// TODO: also run formatting checks once lintel-format exists
31pub async fn run(args: &mut CheckArgs, reporter: &mut dyn Reporter) -> Result<bool> {
32    lintel_validate::run(&mut args.validate, reporter).await
33}