Skip to content

Commit

Permalink
simplify @argv handling
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Aug 31, 2014
1 parent cbce73c commit 032695b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/Mojolicious/Commands.pm
Expand Up @@ -29,14 +29,14 @@ sub detect {
sub _args {
return if __PACKAGE__->detect;
Getopt::Long::Configure(qw(no_auto_abbrev no_ignore_case pass_through));
GetOptionsFromArray $_[0] ? $_[1] : [@{$_[1]}],
GetOptionsFromArray shift,
'h|help' => \$ENV{MOJO_HELP},

This comment has been minimized.

Copy link
@kberov

kberov Aug 31, 2014

Contributor

I think in the documentation should be stated that these options ('h|help','home=s','m|mode=s') can not be used by commands created by authors because they are used here. I have acommand which has short option '-m' and this does not get to the command now. I will change my short option to '-M', but I think the fact that some options turn out to be reserved should be stated. I still can not propose how this could be solved.

'home=s' => \$ENV{MOJO_HOME},
'm|mode=s' => \$ENV{MOJO_MODE};
Getopt::Long::Configure('default');
}

BEGIN { _args(0, \@ARGV) }
BEGIN { _args([@ARGV]) }

sub run {
my ($self, $name, @args) = @_;
Expand All @@ -62,7 +62,7 @@ sub run {
unless $module;

# Run command (remove options shared by all commands)
_args(1, \@args);
_args(\@args);
my $command = $module->new(app => $self->app);
return $help ? $command->help(@args) : $command->run(@args);
}
Expand Down

0 comments on commit 032695b

Please sign in to comment.