From 9e2e70b9186cef7fc5ceba6f99c36fa6df5ed177 Mon Sep 17 00:00:00 2001 From: Eric Park Date: Fri, 24 Nov 2023 11:27:49 -0500 Subject: [PATCH] refactor(release-helper): move out multiple version flag check --- release-helper/src/main.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/release-helper/src/main.rs b/release-helper/src/main.rs index 03c065d4..89557636 100644 --- a/release-helper/src/main.rs +++ b/release-helper/src/main.rs @@ -72,7 +72,7 @@ options are: --major, --minor, --patch" ); return; } - if (*major || *minor) && *patch || (*major && *minor) { + if enabled_version_flag_count(*major, *minor, *patch) > 1 { println!("Only one version flag should be specified."); return; } @@ -101,6 +101,14 @@ fn check_running_directory() -> bool { true } +fn enabled_version_flag_count(major: bool, minor: bool, patch: bool) -> i32 { + let mut count = 0; + if major { count += 1; } + if minor { count += 1; } + if patch { count += 1; } + return count; +} + fn today_iso8601() -> String { let today = OffsetDateTime::now_local().expect("Could not determine the UTC offset on this system!");