Skip to content

Commit 140547d

Browse files
committed
Minor fixes pre-release
1 parent 35f8f3b commit 140547d

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

CHANGELOG.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ Changelog
66

77
### Fixed
88

9-
* Fixed `--greppable` so NDJSON input prints all matching results instead of only the last one.
109
* Fixed conflicting input-format flags so combinations such as `--from-xml --from-yaml` are rejected by the CLI.
1110

1211
### Miscellaneous

src/main.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,12 @@ fn main() -> io::Result<()> {
9595
Ok(results) => {
9696
// Print all outputs, unless void mode is enabled
9797
if !cli.void {
98-
for (output, _) in &results {
99-
if cli.greppable {
98+
if cli.greppable {
99+
if let Some((output, _)) = results.last() {
100100
print!("{}", output);
101-
} else {
101+
}
102+
} else {
103+
for (output, _) in &results {
102104
println!("{}", output);
103105
}
104106
}

tests/golden.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -815,13 +815,11 @@ json.person.name = "Bob";
815815

816816
#[cfg(feature = "greppable")]
817817
test!(
818-
greppable_ndjson_prints_all_results,
818+
greppable_ndjson_prints_only_last_result,
819819
&["--greppable", "-S", "this"],
820820
r#"{"a":1}
821821
{"b":2}"#,
822822
r#"json = {};
823-
json.a = 1;
824-
json = {};
825823
json.b = 2;
826824
"#
827825
);

0 commit comments

Comments
 (0)