#!perl

our $DATE = '2014-08-16'; # DATE
our $VERSION = '0.01'; # VERSION

use 5.010;
use strict;
use warnings;

use App::DzilUtils;
use Perinci::CmdLine::Any -prefer_lite=>1;

our %SPEC;
$SPEC{list_dzil_bundle_contents} = {
    v => 1.1,
    summary => 'List plugins included in a Dist::Zilla plugin bundle',
    args => {
        bundle => {
            schema => 'str*',
            req    => 1,
            pos    => 0,
            completion => $App::DzilUtils::_complete_bundle,
        },
        short => {
            schema => 'bool*',
            cmdline_aliases => {s=>{}},
        },
    },
};
sub list_dzil_bundle_contents {
    require Module::Load;

    my %args = @_;

    my $bundle = $args{bundle};
    $bundle =~ s/^Dist::Zilla::PluginBundle:://;
    $bundle =~ s!/!::!g; # convenience

    my $module = "Dist::Zilla::PluginBundle::$bundle";
    Module::Load::load($module);

    my $obj = $module->new(name => 'bundle', payload=>{});
    $obj->configure;

    my $plugins = $obj->plugins;
    my $res = [];
    for (@$plugins) {
        if ($args{short}) {
            $_->[1] =~ s/^Dist::Zilla::Plugin:://;
            push @$res, $_->[1];
        } else {
            push @$res, [$_->[0], $_->[1]];
        }
    }

    [200, "OK", $res];
}

Perinci::CmdLine::Any->new(
    url => '/main/list_dzil_bundle_contents',
)->run;

# ABSTRACT: List plugins included in a Dist::Zilla plugin bundle
# PODNAME: list-dzil-bundle-contents

__END__

=pod

=encoding UTF-8

=head1 NAME

list-dzil-bundle-contents - List plugins included in a Dist::Zilla plugin bundle

=head1 VERSION

This document describes version 0.01 of list-dzil-bundle-contents (from Perl distribution App-DzilUtils), released on 2014-08-16.

=head1 SYNOPSIS

 % list-dzil-bundle-contents Author::SHARYANTO

To active bash completion:

 % complete -C list-dzil-bundle-contents list-dzil-bundle-contents ; # can be put in bash startup file e.g. .bashrc
 % list-dzil-bundle-contents author/sharya<tab>
 % list-dzil-bundle-contents "Author::SHARYA<tab>  ; # use quote (' or ") if you want to use :: as separator

=head1 HOMEPAGE

Please visit the project's homepage at L<https://metacpan.org/release/App-DzilUtils>.

=head1 SOURCE

Source repository is at L<https://github.com/sharyanto/perl-App-DzilUtils>.

=head1 BUGS

Please report any bugs or feature requests on the bugtracker website L<https://rt.cpan.org/Public/Dist/Display.html?Name=App-DzilUtils>

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.

=head1 AUTHOR

Steven Haryanto <stevenharyanto@gmail.com>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2014 by Steven Haryanto.

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
