| 1 | package Dist::Zilla::App::Command::gh; | ||
| 2 | # ABSTRACT: Use the GitHub plugins from the command-line | ||
| 3 | |||
| 4 | use strict; | ||
| 5 | use warnings; | ||
| 6 | |||
| 7 | our $VERSION = '0.49'; | ||
| 8 | |||
| 9 | use Dist::Zilla::App -command; | ||
| 10 | |||
| 11 | #pod =head1 SYNOPSIS | ||
| 12 | #pod | ||
| 13 | #pod # create a new GitHub repository for your dist | ||
| 14 | #pod $ dzil gh create [<repository>] | ||
| 15 | #pod | ||
| 16 | #pod # update GitHub repo information | ||
| 17 | #pod $ dzil gh update | ||
| 18 | #pod | ||
| 19 | #pod =cut | ||
| 20 | |||
| 21 | sub abstract { 'use the GitHub plugins from the command-line' } | ||
| 22 | sub description { 'Use the GitHub plugins from the command-line' } | ||
| 23 | sub usage_desc { '%c %o [ update | create [<repository>] ]' } | ||
| 24 | |||
| 25 | sub opt_spec { | ||
| 26 | [ 'profile|p=s', 'name of the profile to use', | ||
| 27 | { default => 'default' } ], | ||
| 28 | |||
| 29 | [ 'provider|P=s', 'name of the profile provider to use', | ||
| 30 | { default => 'Default' } ], | ||
| 31 | } | ||
| 32 | |||
| 33 | sub execute { | ||
| 34 | my ($self, $opt, $arg) = @_; | ||
| 35 | |||
| 36 | my $zilla = $self->zilla; | ||
| 37 | |||
| 38 | $_->gather_files for | ||
| 39 | eval { Dist::Zilla::App->VERSION('7.000') } | ||
| 40 | ? $zilla->plugins_with(-FileGatherer) | ||
| 41 | : @{ $zilla->plugins_with(-FileGatherer) }; | ||
| 42 | |||
| 43 | if ($arg->[0] eq 'create') { | ||
| 44 | require Dist::Zilla::Dist::Minter; | ||
| 45 | |||
| 46 | my $minter = Dist::Zilla::Dist::Minter->_new_from_profile( | ||
| 47 | [ $opt->provider, $opt->profile ], { | ||
| 48 | chrome => $self->app->chrome, | ||
| 49 | name => $zilla->name, | ||
| 50 | }, | ||
| 51 | ); | ||
| 52 | |||
| 53 | my $create = _find_plug($minter, 'GitHub::Create'); | ||
| 54 | my $root = `pwd`; chomp $root; | ||
| 55 | my $repo = $arg->[1]; | ||
| 56 | |||
| 57 | $create->after_mint({ | ||
| 58 | mint_root => $root, | ||
| 59 | repo => $repo, | ||
| 60 | descr => $zilla->abstract | ||
| 61 | }); | ||
| 62 | } elsif ($arg->[0] eq 'update') { | ||
| 63 | _find_plug($zilla, 'GitHub::Update')->after_release; | ||
| 64 | } | ||
| 65 | } | ||
| 66 | |||
| 67 | sub _find_plug { | ||
| 68 | my ($self, $name) = @_; | ||
| 69 | |||
| 70 | foreach (@{ $self->plugins }) { | ||
| 71 | return $_ if $_->plugin_name =~ /$name/; | ||
| 72 | } | ||
| 73 | } | ||
| 74 | |||
| 75 | 1; # End of Dist::Zilla::App::Command::gh | ||
| 76 | |||
| 77 | __END__ |