#! /usr/bin/env perl

BEGIN {
        my $default_cmd = "search";
        unshift @ARGV, $default_cmd unless $ARGV[0] =~ /search|help|commands/;
}

use App::DPath;
my $app = App::DPath->new;
$app->run;

=head1 NAME

dpath - Cmdline tool around Data::DPath

=head1 SYNOPSIS

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 JSON, Output is Data::Dumper:

  $ dpath -i json -o dumper '//some/dpath' data.json

The following B<input formats> are allowed, with their according
modules used to convert the input into a data structure:

 yaml   - YAML::Syck (default)
 json   - JSON
 ini    - Config::INI::Reader
 dumper - Data::Dumper (including the leading $VAR1 variable assignment)
 tap    - TAP::DOM

The following B<output formats> are allowed:

 yaml   - YAML::Syck (default)
 json   - JSON
 ini    - Config::INI::Writer
 dumper - Data::Dumper (including the leading $VAR1 variable assignment)

For more information about the DPath syntax, see the Perl module
L<Data::DPath|Data::DPath>.

=cut
