Skip to content

Commit

Permalink
Add --nocreate option
Browse files Browse the repository at this point in the history
  • Loading branch information
mohawk2 committed Sep 1, 2015
1 parent dab909d commit 3b55125
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions tool/enchant
Expand Up @@ -10,6 +10,7 @@ use HTTP::Request;
use LWP::UserAgent;
use Moo;
use JSON::MaybeXS;
use Getopt::Long qw(GetOptionsFromArray);

use strict;
use warnings;
Expand All @@ -19,15 +20,17 @@ use constant PATH_TO_GITHUB_CONFIG => "$ENV{HOME}/.git-hub/config";
use constant IRC_JSON => <<JSON;
JSON

has [ qw(github_org github_repo github_user github_password) ] => ( is => 'rw' );
has [
qw(github_org github_repo github_user github_password create)
] => ( is => 'rw' );

has ua => ( is => 'lazy' ); # _build_ua
sub _build_ua {
LWP::UserAgent->new;
}

sub usage {
die "$0 [repo|org/repo]\n";
die "$0 [--nocreate] [repo|org/repo]\n";
}

sub main {
Expand All @@ -37,7 +40,7 @@ sub main {

my $self = $class->_BUILD( @ARGV );

$self->create_repo();
$self->create_repo() if $self->create;
$self->add_hooks();
$self->manual_issue();
}
Expand All @@ -56,10 +59,16 @@ sub request {
sub _BUILD {
my ($class, @args) = @_;

my $create = 1;
return $class->usage unless GetOptionsFromArray(
\@args,
"create!" => \$create,
);
my $target = shift @args;
return $class->usage unless $target;

my $self = $class->new;
$self->create($create);
if( $target =~ m|/| ) {
# if the target contains a slash
my ($org, $repo) = split m|/|, $target;
Expand Down

0 comments on commit 3b55125

Please sign in to comment.