core: remove unnecessary if statement in update control

This commit is contained in:
John Shin 2023-05-02 12:49:49 -07:00
parent 460d346069
commit 3b8f3d04f4

View file

@ -122,16 +122,12 @@ pub mod arguments {
/// assert_eq!(update_mode, UpdateMode::ReplaceAll)
/// }
pub fn determine_update_mode(matches: &ArgMatches) -> UpdateMode {
if matches.contains_id(arguments::OPT_UPDATE) {
if let Some(mode) = matches.get_one::<String>(arguments::OPT_UPDATE) {
match mode.as_str() {
"all" => UpdateMode::ReplaceAll,
"none" => UpdateMode::ReplaceNone,
"older" => UpdateMode::ReplaceIfOlder,
_ => unreachable!("other args restricted by clap"),
}
} else {
unreachable!("other args restricted by clap")
if let Some(mode) = matches.get_one::<String>(arguments::OPT_UPDATE) {
match mode.as_str() {
"all" => UpdateMode::ReplaceAll,
"none" => UpdateMode::ReplaceNone,
"older" => UpdateMode::ReplaceIfOlder,
_ => unreachable!("other args restricted by clap"),
}
} else if matches.get_flag(arguments::OPT_UPDATE_NO_ARG) {
// short form of this option is equivalent to using --update=older