Avoid printing docs on cargo dev generate-all (#3890)

This commit is contained in:
Charlie Marsh 2023-04-05 14:18:33 -04:00 committed by GitHub
parent e0bccfd2d9
commit ac87137c1c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -14,11 +14,11 @@ pub struct Args {
#[derive(Copy, Clone, PartialEq, Eq, clap::ValueEnum, Default)]
pub enum Mode {
/// Update the content in the `configuration.md`
/// Update the content in the `configuration.md`.
#[default]
Write,
/// Don't write to the file, check if the file is up-to-date and error if not
/// Don't write to the file, check if the file is up-to-date and error if not.
Check,
/// Write the generated help to stdout (rather than to `docs/configuration.md`).
@ -26,21 +26,16 @@ pub enum Mode {
}
impl Mode {
const fn is_check(self) -> bool {
matches!(self, Mode::Check)
}
pub(crate) const fn is_dry_run(self) -> bool {
matches!(self, Mode::DryRun)
}
}
pub fn main(args: &Args) -> Result<()> {
// Not checked in
if !args.mode.is_check() {
generate_docs::main(&generate_docs::Args { dry_run: true })?;
}
generate_json_schema::main(&generate_json_schema::Args { mode: args.mode })?;
generate_cli_help::main(&generate_cli_help::Args { mode: args.mode })?;
generate_docs::main(&generate_docs::Args {
dry_run: args.mode.is_dry_run(),
})?;
Ok(())
}