App-Easer
view release on metacpan or search on metacpan
lib/App/Easer/V1.pm view on Meta::CPAN
my $args;
($executable, $args) = ($executable->{executable}, $executable)
if 'HASH' eq ref $executable;
$executable = $cache->{$executable . ' ' . $default_subname} //=
$factory->($executable, $default_subname)
if 'CODE' ne ref $executable;
return $executable unless $args;
return sub { $executable->($args, @_) };
} ## end sub stock_factory
sub stock_help ($self, $config, $args) {
print_help($self, get_descendant($self, $self->{trail}[-2][0], $args));
return 0;
} ## end sub stock_help
sub stock_DefaultSources { [qw< +Default +CmdLine +Environment +Parent >] }
sub stock_SourcesWithFiles {
[
qw< +Default +CmdLine +Environment +Parent
+JsonFileFromConfig +JsonFiles
>
]
} ## end sub stock_SourcesWithFiles
sub validate_configuration ($self, $spec, $args) {
my $from_spec = $spec->{validate};
my $from_self = $self->{application}{configuration}{validate};
my $validator;
if (defined $from_spec && 'HASH' ne ref $from_spec) {
$validator = $self->{factory}->($from_spec, 'validate');
}
elsif (defined $from_self && 'HASH' ne ref $from_self) {
$validator = $self->{factory}->($from_self, 'validate');
}
else { # use stock one
$validator = \¶ms_validate;
}
$validator->($self, $spec, $args);
} ## end sub validate_configuration
exit run(
$ENV{APPEASER} // {
commands => {
MAIN => {
name => 'main app',
help => 'this is the main app',
description => 'Yes, this really is the main app',
options => [
{
name => 'foo',
description => 'option foo!',
getopt => 'foo|f=s',
environment => 'FOO',
default => 'bar',
},
],
execute => sub ($global, $conf, $args) {
my $foo = $conf->{foo};
say "Hello, $foo!";
return 0;
},
'default-child' => '', # run execute by default
},
},
},
[@ARGV]
) unless caller;
1;
( run in 1.156 second using v1.01-cache-2.11-cpan-d7f47b0818f )