PrePAN

Sign in to PrePAN

App::YAML::Filter Filter a YAML stream (like jq but for YAML)

Good

Synopsis

# input.yml
foo: bar
baz: fuzz

$ yq 'if .foo eq bar then .baz' < input.yml
fuzz

$ yq 'if .foo eq bar then .' < input.yml
foo: bar
baz: fuzz

$ yq .baz < input.yml
fuzz

Description

This command is meant to make it easy to manipulate and filter YAML streams using a simple filter language.

It takes its inspiration from jq. I feel YAML is a better language for working with documents on the command line. When possible, I will adhere to jq's filter language for interoperability.

Right now I only implement the filters I need, but there's lots of stuff that jq can do that I will want to do.

If there is a better name for this, I'm open to it. App::yq perhaps? App::YAML::Filter maybe?

Comments

I'm liking App::YAML::Filter more and more.

I'm also not sure I want to maintain jq's syntax, since I don't like it. The Marpa parser would be capable of so much more, and we're (currently written in) Perl, so there's so much else we can do...
I'm voting for yq or something short to type on the cli.

I'm not too crazy on jq's syntax either, but I can live with it. Especially since it's C and very speedy.

Whatever you do, please keep things short :)
I'd always keep the "yq" cli script, it's just a matter of what CPAN thinks the module is called. "App::cpanminus" gets me cpanm, and I always forget that it's not App::cpanm.

I might also want to add y2j and j2y (yaml to json and json to yaml respectively).

Let's go with App::YAML::Filter and see what happens...

Please sign up to post a review.