#!perl

our $DATE = '2016-01-17'; # DATE
our $VERSION = '0.02'; # VERSION

use 5.010;
use strict;
use warnings;

use App::LedgerUtils;
use Data::Clean::JSON;
use Perinci::CmdLine::Any;

our %SPEC;
$SPEC{parse_ledger} = {
    v => 1.1,
    summary => 'Parse Ledger using Ledger::Parser and display the raw parse result',
    description => <<'_',

Mostly only useful for developer for debugging purposes.

If the result is undef (null in JSON), you can use the `--no-naked` option to
see the error message.

_
    args => {
        %App::LedgerUtils::common_args,
    },
    result_naked => 1,
    'cmdline.default_format' => 'json-pretty',
};
sub parse_ledger {
    my %args = @_;

    my $parser = App::LedgerUtils::_get_parser(\%args);

    my $res = $parser->read_string($args{ledger})->{_parsed};
    $res;
}

my $cli = Perinci::CmdLine::Any->new(
    url => '/main/parse_ledger',
    pass_cmdline_object => 1,
    cleanser => Data::Clean::JSON->new(-circular=>[clone => 0]),
);

# so help message can be more helpful
$cli->{common_opts}{format}{default} = 'json-pretty';
$cli->{common_opts}{naked_res}{default} = 1;

$cli->run;

# ABSTRACT: Parse Ledger using Ledger::Parser and display the raw parse result
# PODNAME: parse-ledger

__END__

=pod

=encoding UTF-8

=head1 NAME

parse-ledger - Parse Ledger using Ledger::Parser and display the raw parse result

=head1 VERSION

version 0.02

=head1 AUTHOR

perlancar <perlancar@cpan.org>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2016 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.

=cut
