#!/usr/bin/env -S nu --stdin def "parse filter" [ ] { $in | parse --regex '^(?[^=]+)=(?.*)' | first | update params {|row| $row.params | parse --regex `(?[^=]+)=(?[^:]+):?` } } def "filter to-string" [] { each { |filter| $'($filter.name)=($filter.params | format '{param}={value}')' } | str join ':' } def "complex-filters to-string" [ --pretty-print (-p) ]: table, filters: table>, output: string> -> string { $in | update filters { |$row| $row.filters | flatten | filter to-string } | update input { |row| $row.input | str join '][' } | format '[{input}]{filters}[{output}]' | str join (";" + (if $pretty_print { "\n" } else { "" })) | str replace --all '[]' '' }