Use parsed CLI arguments to detect number flags

Signed-off-by: cuishuang <imcusg@gmail.com>
This commit is contained in:
cuishuang committed 2026-09-04 11:00:36 +08:00
1 parent 2ed8b010af
commit b784eaf0ae
3 files changed
+38 -53

No files matched your search

+27
View File
@@ -250,6 +250,33 @@ fn repeated_combined_flags_use_last_number_or_plain_flag() {
.stdout(" 1 line 1\n \n \n \n 2 line 5\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n 3 line 20\n 4 line 21\n \n \n 5 line 24\n \n 6 line 26\n \n \n \n 7 line 30\n");
}
#[test]
fn option_terminator_keeps_filename_from_number_flags() {
let tmp_dir = tempdir().expect("can create temporary directory");
std::fs::write(tmp_dir.path().join("-b"), "hello\nworld\n").expect("can write temporary file");
bat()
.current_dir(tmp_dir.path())
.args(["--", "-b"])
.assert()
.success()
.stdout("hello\nworld\n");
}
#[test]
fn attached_short_option_values_are_not_treated_as_flags() {
let tmp_dir = tempdir().expect("can create temporary directory");
std::fs::write(tmp_dir.path().join("input.txt"), "hello\nworld\n")
.expect("can write temporary file");
bat()
.current_dir(tmp_dir.path())
.args(["-lbn", "input.txt"])
.assert()
.success()
.stdout("hello\nworld\n");
}
#[test]
fn number_nonblank_style() {
bat()