Skip to content

Commit

Permalink
Merge pull request #51 from Urban-Analytics-Technology-Platform/year-…
Browse files Browse the repository at this point in the history
…search-bug

Error if start year after end year
  • Loading branch information
penelopeysm authored Jun 27, 2024
2 parents 467699d + b632fc6 commit bdf3c19
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,13 @@ fn parse_year_range(value: &str) -> Result<YearRange, &'static str> {
[Some(a)] => Ok(YearRange::Between(*a, *a)),
[None, Some(a)] => Ok(YearRange::Before(*a)),
[Some(a), None] => Ok(YearRange::After(*a)),
[Some(a), Some(b)] => Ok(YearRange::Between(*a, *b)),
[Some(a), Some(b)] => {
if a > b {
Err("Invalid year range")
} else {
Ok(YearRange::Between(*a, *b))
}
}
_ => Err("Invalid year range"),
}
}
Expand Down

0 comments on commit bdf3c19

Please sign in to comment.