From cfa03ad740bd6f1d6aac57f589bd69a0fc26556e Mon Sep 17 00:00:00 2001 From: Kazuhito Hokamura Date: Sat, 30 Nov 2013 15:14:46 +0900 Subject: [PATCH] Remove $opts --- nodebrew | 24 ++++++------------------ t/utils.t | 16 ---------------- 2 files changed, 6 insertions(+), 34 deletions(-) diff --git a/nodebrew b/nodebrew index de6edd6..e82b5d7 100755 --- a/nodebrew +++ b/nodebrew @@ -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); @@ -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 { @@ -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, @@ -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; diff --git a/t/utils.t b/t/utils.t index 17f926c..6435689 100644 --- a/t/utils.t +++ b/t/utils.t @@ -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',