Skip to content

Commit b7c8860

Browse files
committed
cli_args.rs: handle case of another option following --line-numbers
So for example, calling: diffr --line-numbers --help was resulting in error before this commit: unexpected line number style: got '--help', expected aligned|compact Works now.
1 parent 3088ca5 commit b7c8860

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/cli_args.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,9 +307,13 @@ fn color(config: &mut AppConfig, args: &mut Peekable<impl Iterator<Item = String
307307

308308
fn line_numbers(config: &mut AppConfig, args: &mut Peekable<impl Iterator<Item = String>>) -> bool {
309309
let spec = if let Some(spec) = args.peek() {
310-
let parse_result = parse_line_number_style(config, Some(&*spec));
311-
args.next();
312-
parse_result
310+
if spec.starts_with("--") { // next option
311+
parse_line_number_style(config, None)
312+
} else {
313+
let parse_result = parse_line_number_style(config, Some(&*spec));
314+
args.next();
315+
parse_result
316+
}
313317
} else {
314318
parse_line_number_style(config, None)
315319
};

0 commit comments

Comments
 (0)