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
1 changed files with 5 additions and 10 deletions

View File

@ -14,11 +14,11 @@ pub struct Args {
#[derive(Copy, Clone, PartialEq, Eq, clap::ValueEnum, Default)] #[derive(Copy, Clone, PartialEq, Eq, clap::ValueEnum, Default)]
pub enum Mode { pub enum Mode {
/// Update the content in the `configuration.md` /// Update the content in the `configuration.md`.
#[default] #[default]
Write, 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, Check,
/// Write the generated help to stdout (rather than to `docs/configuration.md`). /// Write the generated help to stdout (rather than to `docs/configuration.md`).
@ -26,21 +26,16 @@ pub enum Mode {
} }
impl Mode { impl Mode {
const fn is_check(self) -> bool {
matches!(self, Mode::Check)
}
pub(crate) const fn is_dry_run(self) -> bool { pub(crate) const fn is_dry_run(self) -> bool {
matches!(self, Mode::DryRun) matches!(self, Mode::DryRun)
} }
} }
pub fn main(args: &Args) -> Result<()> { 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_json_schema::main(&generate_json_schema::Args { mode: args.mode })?;
generate_cli_help::main(&generate_cli_help::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(()) Ok(())
} }