From 3dde8f9c2d4352c12e19039178fa42ea4250cbeb Mon Sep 17 00:00:00 2001 From: Ɓukasz Niemier <~@hauleth.dev> Date: Thu, 15 Aug 2024 12:08:02 +0000 Subject: [PATCH] ft: set default ordering for size filter --- cli/src/filters.rs | 6 +++++- docs/ptsd.json.5.scd | 14 ++++++++++++-- 2 file(s) changed, 17 insertion(s)(+), 3 deletion(s)(-) diff --git a/cli/src/filters.rs b/cli/src/filters.rs --- a/cli/src/filters.rs +++ b/cli/src/filters.rs @@ -77,11 +77,15 @@ Equal, Greater, } +impl Ordering { + fn default() -> std::cmp::Ordering { std::cmp::Ordering::Equal } +} + filter! { "size"; struct Size { size: u64, - #[serde(with = "Ordering")] + #[serde(with = "Ordering", default = "Ordering::default")] ordering: std::cmp::Ordering, }; (self, path) -> { diff --git a/docs/ptsd.json.5.scd b/docs/ptsd.json.5.scd --- a/docs/ptsd.json.5.scd +++ b/docs/ptsd.json.5.scd @@ -32,7 +32,7 @@ *name* Match name of the file against pattern. Available options (exclusive): - *exact* - match name exactly - - *wildcard* - match name agains wildcard pattern + - *wildcard* - match name against wildcard pattern - *regex* - match name against regular expression *file_type* @@ -44,7 +44,7 @@ - *is* - string that can be one of *dir*, *file*, *symlink* and will return if subject of the test point to file of that type *content_type* - Match agains content type. + Match against content type. Options: @@ -54,6 +54,16 @@ - *magic* - object with field *bytes* that is array of integers within range 0..255 that describe magic bytes that will be read from the file and matched. Optionally there can be also used option *offset* that describes offset from the beginning of the file for the pattern. + +*size* + Match against file size. + + Options: + + - *size* - value which will be compared with the file size + - *ordering* - one of *grater*, *equal*, *less* which determines what + comparison operator will be used. + There are also meta filters: -- tangled.sh