Skip to content

Commit

Permalink
Remove $opts
Browse files Browse the repository at this point in the history
  • Loading branch information
hokaccha committed Nov 30, 2013
1 parent 9b5c7a1 commit cfa03ad
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 34 deletions.
24 changes: 6 additions & 18 deletions nodebrew
Expand Up @@ -55,12 +55,12 @@ sub init {
}

sub run {
my ($self, $command, $args, $opts) = @_;
my ($self, $command, $args) = @_;

$command ||= '';
$command =~ s/-/_/g;
if (my $cmd = $self->can("_cmd_$command")) {
$cmd->($self, $args, $opts);
$cmd->($self, $args);
}
else {
$self->_cmd_help($args);
Expand Down Expand Up @@ -561,21 +561,9 @@ sub find_version {
}

sub parse_args {
my $opts = {};
my @args;
my $command = shift;

for (@_) {
if ($_ =~ m/^-(\w)/) {
$opts->{$1} = 1;
}
else {
push @args, $_;
}
}

my $command = shift @args;

return ($command, \@args, $opts);
return ($command, \@_);
}

sub system_info {
Expand Down Expand Up @@ -777,7 +765,7 @@ sub main {
my $fetcher_type = `which curl` ? 'curl' :
`which wget` ? 'wget' :
die 'Need curl or wget';
my ($command, $args, $opts) = Nodebrew::Utils::parse_args(@ARGV);
my ($command, $args) = Nodebrew::Utils::parse_args(@ARGV);

Nodebrew->new(
brew_dir => $brew_dir,
Expand All @@ -791,7 +779,7 @@ sub main {
tarballs_binary => [
"http://nodejs.org/dist/#{version}/node-#{version}-#{platform}-#{arch}.tar.gz",
],
)->run($command, $args, $opts);
)->run($command, $args);
}

main() unless caller;
16 changes: 0 additions & 16 deletions t/utils.t
Expand Up @@ -89,22 +89,6 @@ is Nodebrew::Utils::find_version('stable', [
is $args->[0], '0.1';
}

{
my ($command, $args, $opt)
= Nodebrew::Utils::parse_args('install', '-p', 'v0.8.0');
is $command, 'install';
is_deeply $args, ['v0.8.0'];
is_deeply $opt, { p => 1 };
}

{
my ($command, $args, $opt)
= Nodebrew::Utils::parse_args('install', 'v0.8.0', '-p');
is $command, 'install';
is_deeply $args, ['v0.8.0'];
is_deeply $opt, { p => 1 };
}

is Nodebrew::Utils::apply_vars('key-#{key1}-#{key2}-#{key1}', {
key1 => 'val1',
key2 => 'val2',
Expand Down

0 comments on commit cfa03ad

Please sign in to comment.