view release on metacpan or search on metacpan
xt/compat/commands.t view on Meta::CPAN
use File::Temp 'tempdir';
# Make sure @ARGV is not changed
{
local $ENV{MOJO_MODE};
local @ARGV = qw(-m production -x whatever);
require Mojolicious::Commands;
is $ENV{MOJO_MODE}, 'production', 'right mode';
is_deeply \@ARGV, [qw(-m production -x whatever)], 'unchanged';
}
xt/compat/commands.t view on Meta::CPAN
# Do not pick up options for detected environments
{
local $ENV{MOJO_MODE};
local $ENV{PLACK_ENV} = 'testing';
local @ARGV = qw(psgi -m production);
is ref Mojolicious::Commands->start_app('MojoliciousTest'), 'CODE',
'right reference';
is $ENV{MOJO_MODE}, undef, 'no mode';
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Mojolicious/Plugin/Util/Endpoint/endpoints.pm view on Meta::CPAN
# Run endpoints
sub run {
my $self = shift;
# Options
local @ARGV = @_;
my $c = $self->app->build_controller;
$c->app($self->app);
# Get endpoints
view all matches for this distribution
view release on metacpan or search on metacpan
$rv;
}
sub usage
{
my($usage) = do { local(@ARGV,$/)=($0); <> } =~ /^=head\d$HS+SYNOPSIS\s*^(.*?)\s*^=/ms;
my %M = ( 'I' => '*' );
$usage =~ s/^\s*perl\s+\S+/$^X $0/;
$usage =~ s/([A-Z])<([^>]+)>/$M{$1}$2$M{$1}/g;
print <<ENDUSAGE;
exit 2;
}
sub strip
{
my $self = do { local(@ARGV,$/)=($0); <> };
my($copy) = $self =~ /^=head\d\s+COPYRIGHT\s*^(.*?)^=\w+/ms;
$copy =~ s/^(?=\S+)/ /gms;
$self =~ s/^$HS+Do NOT edit.*?(?=^-)/$copy/ms;
$self =~ s/^SKIP.*(?=^__DATA__)/SKIP
if (\@ARGV && \$ARGV[0] eq '--unstrip') {
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Monitoring/GLPlugin.pm view on Meta::CPAN
sub init {
my ($self) = @_;
if ($self->opts->can("blacklist") && $self->opts->blacklist &&
-f $self->opts->blacklist) {
$self->opts->blacklist = do {
local (@ARGV, $/) = $self->opts->blacklist; <> };
}
}
sub dumper {
my ($self, $object) = @_;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/MooX/Cmd/Tester.pm view on Meta::CPAN
my ($stdout, $stderr, $merged, $ok) = _capture_merged
{
eval {
local $TEST_IN_PROGRESS = 1;
local @ARGV = @$argv;
my $tb = $CLASS->builder();
$cmd = ref $app ? $app : $app->new_with_cmd;
ref $app and $app = ref $app;
view all matches for this distribution
view release on metacpan or search on metacpan
t/testmxopt.pm view on Meta::CPAN
my @cfg_files = map { ("--config-files", File::Spec->catfile($cwd, qw(calc etc), $_)) }
qw(operands.json small-operands.json large-operands.json);
SCOPE:
{
local @ARGV = qw(--config-prefix calc-operands);
my $adder = oCalc::add->new_with_options;
ok(defined($adder->a), "read \"a\" from add config");
ok(defined($adder->b), "read \"b\" from add config");
cmp_ok($adder->execute, "==", 5, "read right adder config");
ok(Moo::Role::does_role($adder, "MooX::ConfigFromFile::Role"), "Applying MooX::ConfigFromFile::Role to oCalc::add");
}
SCOPE:
{
local @ARGV = qw(--config-prefix operands);
my $subber = oCalc::sub->new_with_options;
ok(defined($subber->a), "read \"a\" from sub config");
ok(defined($subber->b), "read \"b\" from sub config");
cmp_ok($subber->execute, "==", 17, "read right subber config");
ok(Moo::Role::does_role($subber, "MooX::ConfigFromFile::Role"), "Applying MooX::ConfigFromFile::Role to oCalc::sub");
}
SCOPE:
{
local @ARGV = @cfg_files[0 .. 1];
my $mul = oCalc::mul->new_with_options;
is($mul->a, 21,, "read \"a\" from mul config");
is($mul->b, 4, "read \"b\" from mul config");
cmp_ok($mul->execute, "==", 84, "read right mul config");
}
SCOPE:
{
local @ARGV = @cfg_files[2 .. 3];
my $mul = oCalc::mul->new_with_options;
is($mul->a, 21,, "keep \"a\" from first mul config");
is($mul->b, 4, "keep \"b\" from first mul config");
cmp_ok($mul->execute, "==", 84, "read right mul config");
}
SCOPE:
{
local @ARGV = @cfg_files[2 .. 3];
my $div = oCalc::div->new_with_options;
is($div->a, 30,, "read \"a\" from small div config");
is($div->b, 6, "read \"b\" from small div config");
cmp_ok($div->execute, "==", 5, "read right div config");
}
SCOPE:
{
local @ARGV = @cfg_files[4 .. 5];
my $div = oCalc::div->new_with_options;
is($div->a, 666,, "read \"a\" from large div config");
is($div->b, 222, "read \"b\" from large div config");
cmp_ok($div->execute, "==", 3, "read right div config");
}
view all matches for this distribution
view release on metacpan or search on metacpan
}
my $options_argv;
{
local @ARGV;
@ARGV = ( qw/
--opt
test_string
/ );
$options_argv = My::Test::Class->new_with_options;
is $options_argv->success, 1, 'Command works';
my $actions_argv;
dies_ok {
local @ARGV;
@ARGV = ( qw/
--opt
test_string
/ );
My::Test::Class->new_with_actions;
} 'Dies with no command';
{
local @ARGV;
@ARGV = ( qw/
test
--opt
test_string
/ );
is $actions_argv->success, 1, 'Command works';
my $new_with_argv;
{
local @ARGV;
@ARGV = ( qw/
test
/ );
$new_with_argv = My::Test::Class->new_with_actions( opt => 'test_string' );
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/MooX/Options/Role.pm view on Meta::CPAN
}
my ( $options, $has_to_split, $all_options )
= _options_prepare_descriptive( \%options_data );
local @ARGV = @ARGV if $options_config{protect_argv};
@ARGV = _options_fix_argv( \%options_data, $has_to_split, $all_options );
my @flavour;
if ( defined $options_config{flavour} ) {
push @flavour, { getopt_conf => $options_config{flavour} };
lib/MooX/Options/Role.pm view on Meta::CPAN
{
$usage = shift @messages;
}
$code = 0 if !defined $code;
if ( !$usage ) {
local @ARGV = ();
my %cmdline_params = $class->parse_options( help => $code );
$usage = $cmdline_params{help};
}
my $message = "";
$message .= join( "\n", @messages, '' ) if @messages;
lib/MooX/Options/Role.pm view on Meta::CPAN
sub options_help {
my ( $class, $code, $usage ) = @_;
$code = 0 if !defined $code;
if ( !defined $usage || !ref $usage ) {
local @ARGV = ();
my %cmdline_params = $class->parse_options( help => $code );
$usage = $cmdline_params{help};
}
my $message = $usage->option_help . "\n";
if ( $code > 0 ) {
lib/MooX/Options/Role.pm view on Meta::CPAN
sub options_short_usage {
my ( $class, $code, $usage ) = @_;
$code = 0 if !defined $code;
if ( !defined $usage || !ref $usage ) {
local @ARGV = ();
my %cmdline_params = $class->parse_options( help => $code );
$usage = $cmdline_params{help};
}
my $message = "USAGE: " . $usage->option_short_usage . "\n";
if ( $code > 0 ) {
lib/MooX/Options/Role.pm view on Meta::CPAN
=cut
sub options_man {
my ( $class, $usage, $output ) = @_;
local @ARGV = ();
if ( !$usage ) {
local @ARGV = ();
my %cmdline_params = $class->parse_options( man => 1 );
$usage = $cmdline_params{man};
}
use_module( "Path::Class", "0.32" );
view all matches for this distribution
view release on metacpan or search on metacpan
t/30-create_crypted_password.t view on Meta::CPAN
my $secret_file = catfile($tmp_dir, 'password.private');
note('Create crypted file');
{
local $ENV{PERL5LIB} = 'lib';
local @ARGV = (
'--file-name' => $secret_file,
'--cipher-key' => $cipher_key,
'--password' => $secret,
);
do "bin/create_crypted_password";
view all matches for this distribution
view release on metacpan or search on metacpan
$rv || 0;
}
sub usage
{
my($usage) = do { local(@ARGV,$/)=($0); <> } =~ /^=head\d$HS+SYNOPSIS\s*^(.*?)\s*^=/ms;
my %M = ( 'I' => '*' );
$usage =~ s/^\s*perl\s+\S+/$^X $0/;
$usage =~ s/([A-Z])<([^>]+)>/$M{$1}$2$M{$1}/g;
print <<ENDUSAGE;
exit 2;
}
sub strip
{
my $self = do { local(@ARGV,$/)=($0); <> };
my($copy) = $self =~ /^=head\d\s+COPYRIGHT\s*^(.*?)^=\w+/ms;
$copy =~ s/^(?=\S+)/ /gms;
$self =~ s/^$HS+Do NOT edit.*?(?=^-)/$copy/ms;
$self =~ s/^SKIP.*(?=^__DATA__)/SKIP
if (\@ARGV && \$ARGV[0] eq '--unstrip') {
view all matches for this distribution
view release on metacpan or search on metacpan
lib/MooseX/App/Cmd/Command.pm view on Meta::CPAN
isa => 'MooseX::App::Cmd',
);
override _process_args => sub {
my ($class, $args) = @_;
local @ARGV = @{$args};
my $config_from_file;
if ($class->meta->does_role('MooseX::ConfigFromFile')) {
local @ARGV = @ARGV;
my $configfile;
my $opt_parser;
{
## no critic (Modules::RequireExplicitInclusion)
view all matches for this distribution
view release on metacpan or search on metacpan
lib/MooseX/App/ParsedArgv.pm view on Meta::CPAN
my $option = $self->consume($type);
OR
my $option = $self->consume();
Returns the first option/parameter of the local @ARGV that has not yet been
consumed as a L<MooseX::App::ParsedArgv::Element> object.
=head2 elements
Returns all parsed options and parameters.
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Perl/Tidy.pm view on Meta::CPAN
prefilter => undef,
postfilter => undef,
);
# don't overwrite callers ARGV
local @ARGV = @ARGV;
my %input_hash = @_;
if ( my @bad_keys = grep { !exists $defaults{$_} } keys %input_hash ) {
local $" = ')(';
inc/Perl/Tidy.pm view on Meta::CPAN
#---------------------------------------------------------------
# set the defaults by passing the above list through GetOptions
#---------------------------------------------------------------
my %Opts = ();
{
local @ARGV;
my $i;
# do not load the defaults if we are just dumping perltidyrc
unless ( $dump_options_type eq 'perltidyrc' ) {
for $i (@$rdefaults) { push @ARGV, "--" . $i }
inc/Perl/Tidy.pm view on Meta::CPAN
die $death_message if ($death_message);
# process any .perltidyrc parameters right now so we can
# localize errors
if (@$rconfig_list) {
local @ARGV = @$rconfig_list;
expand_command_abbreviations( $rexpansion, \@raw_options,
$config_file );
if ( !GetOptions( \%Opts, @$roption_string ) ) {
die
"Error in this config file: $config_file \nUse -npro to ignore this file, -h for help'\n";
}
# Anything left in this local @ARGV is an error and must be
# invalid bare words from the configuration file. We cannot
# check this earlier because bare words may have been valid
# values for parameters. We had to wait for GetOptions to have
# a look at @ARGV.
if (@ARGV) {
view all matches for this distribution
view release on metacpan or search on metacpan
lib/MooseX/Getopt/Defanged.pm view on Meta::CPAN
map { $_->get_full_specification($type_metadata) } @option_attributes;
my $parse_worked;
{
local @ARGV = @{$argv_ref};
open my $stderr_handle, '>', \$stderr;
$parse_worked = _getopt_invoke_getopt_long_while_handling_exceptions(
$parser, $stderr_handle, \%option_values, \@specification_strings,
);
view all matches for this distribution
view release on metacpan or search on metacpan
t/01_basic.t view on Meta::CPAN
throws_ok {
MyTestClass->new_with_options();
} qr/First parameter ins't Getopt::Kingpin instance/, 'kingpin instance';
{
local @ARGV = ();
my $kingpin = Getopt::Kingpin->new();
exits_nonzero {
MyTestClass->new_with_options($kingpin);
} 'missing required options';
}
{
local @ARGV = ($0);
my $kingpin = Getopt::Kingpin->new();
my $my = MyTestClass->new_with_options($kingpin);
is($my->input_file, $0, 'required input_file');
is($my->lines, 10, 'default lines');
}
{
local @ARGV = ($0, '--lines', 100);
my $kingpin = Getopt::Kingpin->new();
my $my = MyTestClass->new_with_options($kingpin);
view all matches for this distribution
view release on metacpan or search on metacpan
lib/MooseX/Getopt/Basic.pm view on Meta::CPAN
my $constructor_params = ( @params == 1 ? $params[0] : {@params} );
my $config_from_file;
if($class->meta->does_role('MooseX::ConfigFromFile')) {
local @ARGV = @ARGV;
# just get the configfile arg now out of @ARGV; the rest of the args
# will be fetched later
my $configfile;
my $opt_parser = Getopt::Long::Parser->new( config => [ qw( no_auto_help pass_through no_auto_version ) ] );
lib/MooseX/Getopt/Basic.pm view on Meta::CPAN
sub _getopt_spec { shift->_traditional_spec(@_); }
sub _parse_argv {
my ( $class, %params ) = @_;
local @ARGV = @{ $params{params}{argv} || \@ARGV };
my ( $opt_spec, $name_to_init_arg ) = $class->_getopt_spec(%params);
# Get a clean copy of the original @ARGV
my $argv_copy = [ @ARGV ];
view all matches for this distribution
view release on metacpan or search on metacpan
xt/cover.pl view on Meta::CPAN
chdir '..' or die "$!";
};
do "./Build.PL";
local @ARGV = (@ARGV, 'testcover');
do "./Build";
view all matches for this distribution
view release on metacpan or search on metacpan
lib/MooseX/Runnable/Invocation/Scheme/MooseX/Getopt.pm view on Meta::CPAN
};
around create_instance => sub {
my ($next, $self, $class, @args) = @_;
local @ARGV = @args; # ugly!
my $instance = $class->name->new_with_options();
my $more_args = $instance->extra_argv;
return ($instance, @$more_args);
view all matches for this distribution
view release on metacpan or search on metacpan
lib/MouseX/App/Cmd/Command.pm view on Meta::CPAN
isa => 'MouseX::App::Cmd',
);
override _process_args => sub {
my ( $class, $args ) = @_;
local @ARGV = @{$args};
my $config_from_file;
if ( $class->meta->does_role('MouseX::ConfigFromFile') ) {
local @ARGV = @ARGV;
my $configfile;
my $opt_parser;
{
## no critic (Modules::RequireExplicitInclusion)
view all matches for this distribution
view release on metacpan or search on metacpan
lib/MouseX/Getopt/Basic.pm view on Meta::CPAN
sub new_with_options {
my ($class, @params) = @_;
my $config_from_file;
if($class->meta->does_role('MouseX::ConfigFromFile')) {
local @ARGV = @ARGV;
# just get the configfile arg now; the rest of the args will be
# fetched later
my $configfile;
my $opt_parser = Getopt::Long::Parser->new( config => [ qw( no_auto_help pass_through ) ] );
lib/MouseX/Getopt/Basic.pm view on Meta::CPAN
sub _getopt_spec { shift->_traditional_spec(@_); }
sub _parse_argv {
my ( $class, %params ) = @_;
local @ARGV = @{ $params{params}{argv} || \@ARGV };
my ( $opt_spec, $name_to_init_arg ) = $class->_getopt_spec(%params);
# Get a clean copy of the original @ARGV
my $argv_copy = [ @ARGV ];
view all matches for this distribution
view release on metacpan or search on metacpan
t/02_getopt.t view on Meta::CPAN
isa_ok $obj->dir => 'Path::Class::Dir';
isa_ok $obj->file => 'Path::Class::File';
is $obj->dir => $dir;
is $obj->file => $file;
local @ARGV = qw(--dir /tmp --file /tmp/foo);
my $opt = $class->new_with_options;
isa_ok $opt => $class;
isa_ok $opt->dir => 'Path::Class::Dir';
isa_ok $opt->file => 'Path::Class::File';
is $opt->dir => $dir;
view all matches for this distribution
view release on metacpan or search on metacpan
print " --- hint for $func ---\n", $hint;
}
sub usage
{
my($usage) = do { local(@ARGV,$/)=($0); <> } =~ /^=head\d$HS+SYNOPSIS\s*^(.*?)\s*^=/ms;
my %M = ( 'I' => '*' );
$usage =~ s/^\s*perl\s+\S+/$^X $0/;
$usage =~ s/([A-Z])<([^>]+)>/$M{$1}$2$M{$1}/g;
print <<ENDUSAGE;
view all matches for this distribution
view release on metacpan or search on metacpan
print " --- hint for $func ---\n", $hint;
}
sub usage
{
my($usage) = do { local(@ARGV,$/)=($0); <> } =~ /^=head\d$HS+SYNOPSIS\s*^(.*?)\s*^=/ms;
my %M = ( 'I' => '*' );
$usage =~ s/^\s*perl\s+\S+/$^X $0/;
$usage =~ s/([A-Z])<([^>]+)>/$M{$1}$2$M{$1}/g;
print <<ENDUSAGE;
view all matches for this distribution
view release on metacpan or search on metacpan
print " --- hint for $func ---\n", $hint;
}
sub usage
{
my($usage) = do { local(@ARGV,$/)=($0); <> } =~ /^=head\d$HS+SYNOPSIS\s*^(.*?)\s*^=/ms;
my %M = ( 'I' => '*' );
$usage =~ s/^\s*perl\s+\S+/$^X $0/;
$usage =~ s/([A-Z])<([^>]+)>/$M{$1}$2$M{$1}/g;
print <<ENDUSAGE;
view all matches for this distribution
view release on metacpan or search on metacpan
print " --- hint for $func ---\n", $hint;
}
sub usage
{
my($usage) = do { local(@ARGV,$/)=($0); <> } =~ /^=head\d$HS+SYNOPSIS\s*^(.*?)\s*^=/ms;
my %M = ( 'I' => '*' );
$usage =~ s/^\s*perl\s+\S+/$^X $0/;
$usage =~ s/([A-Z])<([^>]+)>/$M{$1}$2$M{$1}/g;
print <<ENDUSAGE;
view all matches for this distribution
view release on metacpan or search on metacpan
print " --- hint for $func ---\n", $hint;
}
sub usage
{
my($usage) = do { local(@ARGV,$/)=($0); <> } =~ /^=head\d$HS+SYNOPSIS\s*^(.*?)\s*^=/ms;
my %M = ( 'I' => '*' );
$usage =~ s/^\s*perl\s+\S+/$^X $0/;
$usage =~ s/([A-Z])<([^>]+)>/$M{$1}$2$M{$1}/g;
print <<ENDUSAGE;
view all matches for this distribution
view release on metacpan or search on metacpan
print " --- hint for $func ---\n", $hint;
}
sub usage
{
my($usage) = do { local(@ARGV,$/)=($0); <> } =~ /^=head\d$HS+SYNOPSIS\s*^(.*?)\s*^=/ms;
my %M = ( 'I' => '*' );
$usage =~ s/^\s*perl\s+\S+/$^X $0/;
$usage =~ s/([A-Z])<([^>]+)>/$M{$1}$2$M{$1}/g;
print <<ENDUSAGE;
view all matches for this distribution
view release on metacpan or search on metacpan
$rv;
}
sub usage
{
my($usage) = do { local(@ARGV,$/)=($0); <> } =~ /^=head\d$HS+SYNOPSIS\s*^(.*?)\s*^=/ms;
my %M = ( 'I' => '*' );
$usage =~ s/^\s*perl\s+\S+/$^X $0/;
$usage =~ s/([A-Z])<([^>]+)>/$M{$1}$2$M{$1}/g;
print <<ENDUSAGE;
exit 2;
}
sub strip
{
my $self = do { local(@ARGV,$/)=($0); <> };
my($copy) = $self =~ /^=head\d\s+COPYRIGHT\s*^(.*?)^=\w+/ms;
$copy =~ s/^(?=\S+)/ /gms;
$self =~ s/^$HS+Do NOT edit.*?(?=^-)/$copy/ms;
$self =~ s/^SKIP.*(?=^__DATA__)/SKIP
if (\@ARGV && \$ARGV[0] eq '--unstrip') {
view all matches for this distribution
view release on metacpan or search on metacpan
lib/MyCPAN/App/BackPAN/Indexer.pm view on Meta::CPAN
my( $application ) = @_;
my $run_dir = dirname( $0 );
( my $script = basename( $0 ) ) =~ s/\.\w+$//;
local @ARGV = @{ $application->{args} };
getopts( 'cl:f:', \ my %Options );
# other things might want to use things from @ARGV, and
# we just removed the bits that we wanted.
$application->{args} = [ @ARGV ]; # XXX: yuck
view all matches for this distribution
view release on metacpan or search on metacpan
lib/MySQL/ORM/Generate/Writer.pm view on Meta::CPAN
confess "$stdout\n$stderr";
}
return;
#local @ARGV = ('-b', "-bext='/'", $file_name);
#Perl::Tidy::Sweetened::perltidy();
}
#method _tidy (Str $file_name) {
#
view all matches for this distribution