Skip to content

Commit

Permalink
Running cargo semver-checks with no other arguments should default to…
Browse files Browse the repository at this point in the history
… checking (#459)

* cargo semver-checks with no other arguments should default to checking

* Update tests/feature_config.rs

Co-authored-by: Predrag Gruevski <[email protected]>

* addresses comments on PR

* cargo fmt

* Update src/main.rs

Co-authored-by: Predrag Gruevski <[email protected]>

* address comments from pr

* trailing line between constant and method

---------

Co-authored-by: Predrag Gruevski <[email protected]>
  • Loading branch information
era and obi1kenobi authored May 31, 2023
1 parent 817b1ff commit 41ae646
Show file tree
Hide file tree
Showing 2 changed files with 140 additions and 64 deletions.
28 changes: 12 additions & 16 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ fn main() -> anyhow::Result<()> {
)?;
}

let mut config = GlobalConfig::new().set_level(args.verbosity.log_level());
let mut config = GlobalConfig::new().set_level(args.check_release.verbosity.log_level());
config.shell_note("Use `--explain <id>` to see more details")?;
std::process::exit(0);
} else if let Some(id) = args.explain.as_deref() {
Expand All @@ -75,19 +75,15 @@ fn main() -> anyhow::Result<()> {
std::process::exit(0);
}

match args.command {
Some(SemverChecksCommands::CheckRelease(args)) => {
let check: cargo_semver_checks::Check = args.into();
let report = check.check_release()?;
if report.success() {
std::process::exit(0)
} else {
std::process::exit(1);
}
}
None => {
anyhow::bail!("subcommand required");
}
let check: cargo_semver_checks::Check = match args.command {
Some(SemverChecksCommands::CheckRelease(args)) => args.into(),
None => args.check_release.into(),
};
let report = check.check_release()?;
if report.success() {
std::process::exit(0);
} else {
std::process::exit(1);
}
}

Expand All @@ -111,8 +107,8 @@ struct SemverChecks {
#[arg(long, global = true, exclusive = true)]
list: bool,

#[command(flatten)]
verbosity: clap_verbosity_flag::Verbosity<clap_verbosity_flag::InfoLevel>,
#[clap(flatten)]
check_release: CheckRelease,

#[command(subcommand)]
command: Option<SemverChecksCommands>,
Expand Down
Loading

0 comments on commit 41ae646

Please sign in to comment.