Add cargo dev generate-all --check and catch outdated docs in cargo test (#3320)

This commit is contained in:
konstin 2023-03-06 11:28:38 +01:00 committed by GitHub
parent 30c71dc59a
commit 22e6778e17
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 159 additions and 40 deletions

View file

@ -4,22 +4,32 @@ use anyhow::Result;
use crate::{generate_cli_help, generate_docs, generate_json_schema};
pub const REGENERATE_ALL_COMMAND: &str = "cargo dev generate-all";
#[derive(clap::Args)]
pub struct Args {
/// Write the generated artifacts to stdout (rather than to the filesystem).
#[arg(long)]
dry_run: bool,
/// Don't write to the file, check if the file is up-to-date and error if not
#[arg(long)]
check: bool,
}
pub fn main(args: &Args) -> Result<()> {
generate_docs::main(&generate_docs::Args {
dry_run: args.dry_run,
})?;
// Not checked in
if !args.check {
generate_docs::main(&generate_docs::Args {
dry_run: args.dry_run,
})?;
}
generate_json_schema::main(&generate_json_schema::Args {
dry_run: args.dry_run,
check: args.check,
})?;
generate_cli_help::main(&generate_cli_help::Args {
dry_run: args.dry_run,
check: args.check,
})?;
Ok(())
}