diff --git a/src/filter.pest b/src/filter.pest index c4d2e94..9d85022 100644 --- a/src/filter.pest +++ b/src/filter.pest @@ -1,19 +1,34 @@ +# This Pest grammar defines the syntax for filter chains used in the Keep application. +# Filters can be chained with commas and may have named or unnamed options with JSON-like values. + WHITESPACE = _{ " " | "\t" | "\n" | "\r" } +# Top-level rule for parsing multiple filters separated by commas. filters = { filter ~ ("," ~ filters)? } + +# A single filter consisting of a name optionally followed by parenthesized options. filter = { filter_name ~ ("(" ~ options ~ ")")? } + +# The name of a filter, starting with an ASCII letter followed by alphanumeric characters or underscores. filter_name = @{ ASCII_ALPHA ~ (ASCII_ALPHANUMERIC | "_")* } +# A list of comma-separated options within parentheses. options = { option ~ ("," ~ options)? } + +# A single option, optionally with a name followed by an equals sign and a value. option = { (option_name ~ "=")? ~ option_value } + +# The name of an option, starting with an ASCII letter followed by alphanumeric characters or underscores. option_name = @{ ASCII_ALPHA ~ (ASCII_ALPHANUMERIC | "_")* } +# The value of an option, which can be a JSON number, string, or boolean. option_value = { JSON_NUMBER | JSON_STRING | JSON_BOOLEAN } +# JSON number format supporting integers, decimals, and scientific notation. JSON_NUMBER = @{ ("-")? ~ ("0" | ASCII_NONZERO_DIGIT ~ ASCII_DIGIT*) ~ @@ -21,10 +36,12 @@ JSON_NUMBER = @{ (("e" | "E") ~ ("+" | "-")? ~ ASCII_DIGIT+)? } +# JSON string format with escaped characters. JSON_STRING = ${ "\"" ~ (("\\" ~ ANY) | (!("\"" | "\\") ~ ANY))* ~ "\"" } +# JSON boolean values: true or false. JSON_BOOLEAN = ${ "true" | "false" } diff --git a/src/modes/list.rs b/src/modes/list.rs index 0f6081a..8b5ab30 100644 --- a/src/modes/list.rs +++ b/src/modes/list.rs @@ -371,23 +371,4 @@ fn show_list_structured( compression: item.compression, file_size, file_size_formatted, - file_path: item_path.into_os_string().into_string().unwrap_or_default(), - tags, - meta, - }; - - list_items.push(list_item); - } - - match output_format { - OutputFormat::Json => { - println!("{}", serde_json::to_string_pretty(&list_items)?); - } - OutputFormat::Yaml => { - println!("{}", serde_yaml::to_string(&list_items)?); - } - OutputFormat::Table => unreachable!(), - } - - Ok(()) -} + file_path: item_path.into_os_string().into_string \ No newline at end of file