diff --git a/src/pr/pr.rs b/src/pr/pr.rs index 6617f0bb1..2de3a663f 100644 --- a/src/pr/pr.rs +++ b/src/pr/pr.rs @@ -598,10 +598,11 @@ fn build_options( }; // +page option is less priority than --pages - let re = Regex::new(r"\s*\+(\d+)\s*").unwrap(); + let re = Regex::new(r"\s*\+(\d+:*\d*)\s*").unwrap(); let start_page_in_plus_option: usize = match re.captures(&free_args).map(|i| { let unparsed_num = i.get(1).unwrap().as_str().trim(); - unparsed_num.parse::().map_err(|_e| { + let x: Vec<&str> = unparsed_num.split(":").collect(); + x[0].to_string().parse::().map_err(|_e| { PrError::EncounteredErrors(format!("invalid {} argument '{}'", "+", unparsed_num)) }) }) { @@ -609,6 +610,20 @@ fn build_options( _ => 1, }; + let end_page_in_plus_option: Option = match re + .captures(&free_args) + .map(|i| i.get(1).unwrap().as_str().trim()) + .filter(|i| i.contains(":")) + .map(|unparsed_num| { + let x: Vec<&str> = unparsed_num.split(":").collect(); + x[1].to_string().parse::().map_err(|_e| { + PrError::EncounteredErrors(format!("invalid {} argument '{}'", "+", unparsed_num)) + }) + }) { + Some(res) => Some(res?), + _ => None, + }; + let start_page: usize = match matches .opt_str(PAGE_RANGE_OPTION) .map(|i| { @@ -631,7 +646,7 @@ fn build_options( .map(invalid_pages_map) { Some(res) => Some(res?), - _ => None, + _ => end_page_in_plus_option, }; if end_page.is_some() && start_page > end_page.unwrap() { diff --git a/tests/test_pr.rs b/tests/test_pr.rs index af93d949f..863486878 100644 --- a/tests/test_pr.rs +++ b/tests/test_pr.rs @@ -273,6 +273,14 @@ fn test_with_page_range() { expected_test_file_path1, vec![(&"{last_modified_time}".to_string(), &value)], ); + + new_ucmd!() + .args(&["+15:17", test_file_path]) + .succeeds() + .stdout_is_templated_fixture( + expected_test_file_path1, + vec![(&"{last_modified_time}".to_string(), &value)], + ); } #[test]