App-Framework-Lite
view release on metacpan or search on metacpan
lib/App/Framework/Lite.pm view on Meta::CPAN
{
exit $exit_code ;
}
else
{
# check for eval (for testing)
if ($^S)
{
die "End of application. Exit code = $exit_code" ;
}
else
{
carp(@_);
exit $exit_code ;
}
}
}
#----------------------------------------------------------------------------
=item B<usage($level)>
Show usage.
$level is a string containg the level of usage to display
'opt' is equivalent to pod2usage(2)
'help' is equivalent to pod2usage(1)
'man' is equivalent to pod2usage(-verbose => 2)
=cut
sub usage
{
my $this = shift ;
my ($level) = @_ ;
$level ||= "" ;
# TODO: Work out a better way to convert pod without the use of external file!
# get temp file
my $fh = new File::Temp();
my $fname = $fh->filename;
# write pod
my $developer = $level eq 'man-dev' ? 1 : 0 ;
print $fh $this->pod($developer) ;
close $fh ;
# pod2usage
my ($exitval, $verbose) = (0, 0) ;
($exitval, $verbose) = (2, 0) if ($level eq 'opt') ;
($exitval, $verbose) = (1, 0) if ($level eq 'help') ;
($exitval, $verbose) = (0, 2) if ($level =~ /^man/) ;
# make file readable by all - in case we're running as root
chmod 0644, $fname ;
# system("perldoc", $fname) ;
pod2usage(
-verbose => $verbose,
# -exitval => $exitval,
-exitval => 'noexit',
-input => $fname,
-noperldoc =>1,
-title => $this->{name},
-section => 1,
) ;
# remove temp file
unlink $fname ;
}
#============================================================================================
# OPTIONS
#============================================================================================
#----------------------------------------------------------------------------
=item B< options() >
Returns the hash of options/values
=cut
sub options
{
my $this = shift ;
$this->_dbg_prt( ["Options()\n"] ) ;
my $options_href = $this->{_options} ;
return %$options_href ;
}
#----------------------------------------------------------------------------
=item B< Options([%args]) >
Alias to L</options>
=cut
*Options = \&options ;
#----------------------------------------------------------------------------
#
#=item B<_expand_options()>
#
#Expand any variables in the options
#
#=cut
( run in 0.934 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )