dt - CLI data transformer
This document describes version 0.001 of dt (from Perl distribution App-dt), released on 2017-05-18.
% dt [OPTIONS] [FILE]...
Roughly similar to utilities like jq, jt, the App::PipeFilter suite, jsonsel, ddsel, yamlsel, this dt utility can be used to transform data structure on the CLI using Perl code. It accepts one or several files of encoded data structures in several formats (JSON, YAML, Perl), lets you specify Perl code to modify them, and spits them out again in specified format. The input data structures are put into $DATA[0], $DATA[1] and so on. The first data structure is also put in $_.
$DATA[0]
$DATA[1]
$_
Some examples:
Convert JSON to YAML
% dt books.json -o books.yaml
Add a field to records, output to STDOUT
% dt -e 'my $now = time; for (@$DATA) { $_->{status} = $_->{mtime} >= $now-7*86400 ? "new" : "" }' < books.json
Get YAML from STDIN, output it as Perl
% other-cmd | dt -f yaml -F perl -o data
0 on success.
255 on I/O error.
99 on command-line options or input data error.
--overwrite
--default-input-format FORMAT, -f
Set default output format. Default is json. Can also be yaml, perl.
json
yaml
perl
--default-output-format FORMAT, -F
--output FILENAME, -o
Add an output. Format will be guessed from .
If not specified, will output all data to STDOUT.
If set to true, print debugging messages.
Please visit the project's homepage at https://metacpan.org/release/App-dt.
Source repository is at https://github.com/perlancar/perl-App-dt.
Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=App-dt
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.
jq
jt, App::PipeFilter, jsonsel, ddsel, yamlsel
perlancar <perlancar@cpan.org>
This software is copyright (c) 2017 by perlancar@cpan.org.
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::dt, copy and paste the appropriate command in to your terminal.
cpanm
cpanm App::dt
CPAN shell
perl -MCPAN -e shell install App::dt
For more information on module installation, please visit the detailed CPAN module installation guide.