dpath - cmdline tool around Data::DPath
Query some input data with a DPath to stdout.
Default data format (in and out) is YAML, other formats can be specified.
$ dpath '//some/dpath' data.yaml
Use it as filter:
$ dpath '//some/dpath' < data.yaml > result.yaml $ cat data.yaml | dpath '//some/dpath' > result.yaml $ cat data.yaml | dpath '//path1' | dpath '//path2' | dpath '//path3'
Specify that output is YAML(default), JSON or Data::Dumper:
$ dpath -o yaml '//some/dpath' data.yaml $ dpath -o json '//some/dpath' data.yaml $ dpath -o dumper '//some/dpath' data.yaml
Input is JSON:
$ dpath -i json '//some/dpath' data.json
Input is INI:
$ dpath -i ini '//some/dpath' data.ini
Input is TAP:
$ dpath -i tap '//some/dpath' data.tap $ perl t/some_test.t | dpath -i tap '//tests_planned'
Input is TAP::Archive:
$ dpath -i taparchive '//tests_planned' tap.tgz
Input is JSON, Output is Data::Dumper:
$ dpath -i json -o dumper '//some/dpath' data.json
The following input formats are allowed, with their according modules used to convert the input into a data structure:
yaml - YAML::Any (default; not using YAML::Syck) json - JSON xml - XML::Simple ini - Config::INI::Serializer dumper - Data::Dumper (including the leading $VAR1 variable assignment) tap - TAP::DOM tap - TAP::DOM::Archive
The following output formats are allowed:
yaml - YAML::Any (default; not using YAML::Syck) json - JSON xml - XML::Simple ini - Config::INI::Serializer dumper - Data::Dumper (including the leading $VAR1 variable assignment) flat - pragmatic flat output for typical unixish cmdline usage
The flat output format is meant to support typical unixish command line uses. It is not a strong serialization format but works well for simple values nested max 2 levels.
flat
Output looks like this:
Affe Tiger Birne
One outer key per line, key at the beginning of line with a colon (:), inner values separated by semicolon ;:
:
;
coolness:big size:average Eric:The flat one from the 90s
Tuples of key=value separated by semicolon ;:
key=value
Affe:coolness=big;size=average Zomtec:coolness=bit anachronistic;size=average
Values separated by semicolon ;:
Birne:bissel;hinterher;manchmal
One entry per line, entries separated by semicolon ;:
single report string foo bar baz
Affe=amazing moves in the jungle;Zomtec=slow talking speed;Birne=unexpected in many respects
Entries separated by semicolon ;:
line A-1;line A-2;line A-3;line A-4;line A-5 line B-1;line B-2;line B-3;line B-4 line C-1;line C-2;line C-3
--fb ... use [brackets] around outer arrays --fi ... prefix outer array lines with index --separator=; ... use given separator between array entries (defaults to ";")
Such additional markup lets outer arrays look like this:
0:[line A-1;line A-2;line A-3;line A-4;line A-5] 1:[line B-1;line B-2;line B-3;line B-4] 2:[line C-1;line C-2;line C-3] 3:[Affe=amazing moves in the jungle;Zomtec=slow talking speed;Birne=unexpected in many respects] 4:[single report string]
For more information about the DPath syntax, see
perldoc Data::DPath
Steffen Schwigon <ss5@renormalist.net>
This software is copyright (c) 2019 by Steffen Schwigon.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install App::DPath, copy and paste the appropriate command in to your terminal.
cpanm
cpanm App::DPath
CPAN shell
perl -MCPAN -e shell install App::DPath
For more information on module installation, please visit the detailed CPAN module installation guide.