Skip to content

Commit 3e7ce58

Browse files
committed
docs: version 0.8.1 and edition 2024
1 parent 5914349 commit 3e7ce58

File tree

12 files changed

+60
-43
lines changed

12 files changed

+60
-43
lines changed

.vscode/tasks.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
{
66
"label": "Rust: Format",
77
"type": "shell",
8-
"command": "cargo fmt --all",
8+
"command": "cargo fmt --all --check",
99
"group": "build",
1010
"problemMatcher": []
1111
},

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "parsm"
3-
version = "0.2.1"
4-
edition = "2021"
3+
version = "0.8.1"
4+
edition = "2024"
55
authors = ["John Cairns <john@2ad.com>"]
66
description = "Multi-format data processor that understands structured text better than sed or awk. Supports JSON, CSV, YAML, TOML, logfmt, and plain text with powerful filtering and templating."
77
license = "MIT"

src/bin/parsm.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ use std::io;
33
use tracing::debug;
44

55
use parsm::{
6-
csv_parser, parse_command, parse_separate_expressions, process_stream, DetectedFormat,
7-
FilterEngine, FormatDetector, ParsedDSL, ParsedLine,
6+
DetectedFormat, FilterEngine, FormatDetector, ParsedDSL, ParsedLine, csv_parser, parse_command,
7+
parse_separate_expressions, process_stream,
88
};
99

1010
/// Main entry point for the parsm command-line tool.
@@ -194,8 +194,13 @@ fn process_stream_with_filter(
194194
) -> Result<(), Box<dyn std::error::Error>> {
195195
use parsm::StreamingParser;
196196
use std::io::{BufRead, Read, Write};
197-
debug!("process_stream_with_filter called with DSL: filter={:?}, template={:?}, field_selector={:?}, forced_format={:?}",
198-
dsl.filter.is_some(), dsl.template.is_some(), dsl.field_selector.is_some(), forced_format);
197+
debug!(
198+
"process_stream_with_filter called with DSL: filter={:?}, template={:?}, field_selector={:?}, forced_format={:?}",
199+
dsl.filter.is_some(),
200+
dsl.template.is_some(),
201+
dsl.field_selector.is_some(),
202+
forced_format
203+
);
199204

200205
let stdin = io::stdin();
201206
let stdout = io::stdout();
@@ -622,7 +627,7 @@ mod tests {
622627

623628
use serde_json::json;
624629

625-
use parsm::{filter::TemplateItem, FilterEngine};
630+
use parsm::{FilterEngine, filter::TemplateItem};
626631

627632
/// Test JSON filtering with equality comparison.
628633
#[test]

src/dsl/fallback.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ fn try_simple_template_patterns(input: &str) -> Result<ParsedDSL, Box<dyn std::e
100100
});
101101
return Ok(result);
102102
} else if field_name.chars().all(|c| c.is_ascii_digit()) {
103-
trace!("Dollar sign followed by digits only ($0, $1, $20, etc.), treating as numeric literal");
103+
trace!(
104+
"Dollar sign followed by digits only ($0, $1, $20, etc.), treating as numeric literal"
105+
);
104106
result.template = Some(Template {
105107
items: vec![TemplateItem::Literal(input.to_string())],
106108
});
@@ -273,8 +275,7 @@ fn try_parse_and_expression(input: &str) -> Result<ParsedDSL, Box<dyn std::error
273275

274276
trace!(
275277
"try_parse_and_expression: left='{}', right='{}'",
276-
parts[0],
277-
parts[1]
278+
parts[0], parts[1]
278279
);
279280

280281
// Try to parse each part as either a comparison or a truthy field
@@ -513,8 +514,7 @@ fn parse_field_name_for_truthy(name: &str) -> FieldPath {
513514
let base_name = name.strip_suffix('?').unwrap_or(name);
514515
trace!(
515516
"parse_field_name_for_truthy: '{}' -> base: '{}'",
516-
name,
517-
base_name
517+
name, base_name
518518
);
519519
let parts: Vec<String> = base_name.split('.').map(|s| s.to_string()).collect();
520520
let field_path = FieldPath::new(parts);

src/dsl/filter_parser.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl FilterParser {
6060
message: "Expected expression in AND".to_string(),
6161
},
6262
span.start_pos(),
63-
)))
63+
)));
6464
}
6565
};
6666

@@ -75,7 +75,7 @@ impl FilterParser {
7575
message: "Expected expression after AND".to_string(),
7676
},
7777
op_span.end_pos(),
78-
)))
78+
)));
7979
}
8080
};
8181
left = FilterExpr::And(Box::new(left), Box::new(right));
@@ -130,7 +130,7 @@ impl FilterParser {
130130
message: "Expected expression in comparison".to_string(),
131131
},
132132
span.start_pos(),
133-
)))
133+
)));
134134
}
135135
};
136136

src/dsl/grammar.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Main grammar parser using Pest
22
3-
use pest::iterators::Pair;
43
use pest::Parser;
4+
use pest::iterators::Pair;
55
use pest_derive::Parser;
66
use tracing::trace;
77

src/dsl/mod.rs

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -324,29 +324,37 @@ mod tests {
324324
fn test_existing_template_preserved() {
325325
// Field selectors
326326
assert!(parse_command("username").unwrap().field_selector.is_some());
327-
assert!(parse_command("user.profile.bio")
328-
.unwrap()
329-
.field_selector
330-
.is_some());
331-
assert!(parse_command("\"field with spaces\"")
332-
.unwrap()
333-
.field_selector
334-
.is_some());
327+
assert!(
328+
parse_command("user.profile.bio")
329+
.unwrap()
330+
.field_selector
331+
.is_some()
332+
);
333+
assert!(
334+
parse_command("\"field with spaces\"")
335+
.unwrap()
336+
.field_selector
337+
.is_some()
338+
);
335339

336340
// Templates
337341
assert!(parse_command("$name").unwrap().template.is_some());
338342
assert!(parse_command("{${user.name}}").unwrap().template.is_some());
339-
assert!(parse_command("[Hello ${name}!]")
340-
.unwrap()
341-
.template
342-
.is_some());
343+
assert!(
344+
parse_command("[Hello ${name}!]")
345+
.unwrap()
346+
.template
347+
.is_some()
348+
);
343349

344350
// Comparisons
345351
assert!(parse_command("age >= 21").unwrap().filter.is_some());
346-
assert!(parse_command("status != \"deleted\"")
347-
.unwrap()
348-
.filter
349-
.is_some());
352+
assert!(
353+
parse_command("status != \"deleted\"")
354+
.unwrap()
355+
.filter
356+
.is_some()
357+
);
350358
assert!(parse_command("score > 0.5").unwrap().filter.is_some());
351359

352360
// Combined

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ pub mod format_detector;
508508
pub mod parse;
509509
pub mod parser_registry;
510510

511-
pub use dsl::{parse_command, parse_separate_expressions, ParsedDSL};
511+
pub use dsl::{ParsedDSL, parse_command, parse_separate_expressions};
512512
pub use filter::{
513513
ComparisonOp, FieldPath, FilterEngine, FilterExpr, FilterValue, Template, TemplateItem,
514514
};

src/parse.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,10 +1081,12 @@ this,is,csv,but,should,fail
10811081
// Should gracefully handle malformed input
10821082
assert_eq!(value["level"], "error");
10831083
// The parser should treat the rest as the value since no closing \" was found
1084-
assert!(value["msg"]
1085-
.as_str()
1086-
.unwrap()
1087-
.contains("unclosed quote service=api"));
1084+
assert!(
1085+
value["msg"]
1086+
.as_str()
1087+
.unwrap()
1088+
.contains("unclosed quote service=api")
1089+
);
10881090
}
10891091
_ => panic!("Expected logfmt parsing result"),
10901092
}

0 commit comments

Comments
 (0)