Skip to content

Commit

Permalink
Renamed clap argument to target.
Browse files Browse the repository at this point in the history
This is more meaningul than "value", at least currently.
  • Loading branch information
xoen committed Oct 9, 2024
1 parent 42d11d5 commit 11244ee
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ struct Args {

#[clap()]
/// numerical value for a region (1-17) or first part of a UK postcode
pub value: String,
pub target: String,
}

#[tokio::main]
async fn main() {
let args = Args::parse();

// let target: Target = args.value.parse().unwrap_or(Target::NATIONAL);
let target: Target = args.value.parse().unwrap();
let target: Target = args.target.parse().unwrap();

// look for a range if a date was specified
if let Some(start_date) = &args.start_date {
Expand Down Expand Up @@ -76,21 +76,21 @@ mod tests {
fn cli_valid_arguments() {
// single postcode
let args: Args = parsed_args(vec!["BS7"]).unwrap();
assert_eq!(args.value, "BS7");
assert_eq!(args.target, "BS7");

// single region id
parsed_args(vec!["13"]).unwrap();
assert_eq!(args.value, "BS7");
assert_eq!(args.target, "BS7");

// start date / postcode
let args = parsed_args(vec!["--start-date", "2024-05-06", "BS7"]).unwrap();
assert_eq!(args.start_date, Some("2024-05-06".to_string()));
assert_eq!(args.value, "BS7".to_string());
assert_eq!(args.target, "BS7".to_string());

// start date / region id
let args = parsed_args(vec!["--start-date", "2024-05-06", "13"]).unwrap();
assert_eq!(args.start_date, Some("2024-05-06".to_string()));
assert_eq!(args.value, "13".to_string());
assert_eq!(args.target, "13".to_string());

// start date / end date
let args = parsed_args(vec![
Expand All @@ -103,7 +103,7 @@ mod tests {
.unwrap();
assert_eq!(args.start_date, Some("2024-05-06".to_string()));
assert_eq!(args.end_date, Some("2024-07-08".to_string()));
assert_eq!(args.value, "BS7".to_string());
assert_eq!(args.target, "BS7".to_string());

// short names
parsed_args(vec!["-s 2024-05-06", "-e 2024-05-06", "BS7"]).unwrap();
Expand Down

0 comments on commit 11244ee

Please sign in to comment.