/usr/share/perl5/Jifty/Script.pm is in libjifty-perl 1.10518+dfsg-1ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | package Jifty::Script;
use App::CLI;
use base qw/App::CLI App::CLI::Command Jifty::Object/;
use Jifty::Everything;
Jifty::Everything->plugin_commands;
use Pod::Usage;
=head1 NAME
Jifty::Script - Base class for all bin/jifty commands
=head1 METHODS
=head2 prepare
C<prepare> figures out which command to run. If the user wants
C<--help> give them help.
In the normal case, let App::CLI figure out the command-line.
If they have no command on the command-line, but a JIFTY_COMMAND
environment variable, try that. Otherwise, if the GATEWAY_INTERFACE
environment variable is set, assume we are running under CGI with the
C<fastcgi> command. If all fails, shows the help.
=cut
sub prepare {
my $self = shift;
if ($ARGV[0] =~ /--?h(elp)?/i) {
$ARGV[0] = 'help';
}
elsif ( $ARGV[0] =~ /^(-v|--version|version)$/ ) {
print "This is Jifty, version $Jifty::VERSION\n";
exit 0;
}
elsif (!@ARGV) {
if ( my $cmd = $ENV{'JIFTY_COMMAND'} ) {
unshift @ARGV, $cmd;
}
elsif ( $ENV{GATEWAY_INTERFACE} ) {
unshift @ARGV, 'fastcgi';
}
else {
unshift @ARGV, 'help';
}
}
return $self->SUPER::prepare(@_);
}
=head2 options
=cut
sub options {
return (
'h|help|?' => 'help',
'man' => 'man',
);
}
=head2 alias
The alias table lets users type C<fastcgi> in place of C<FastCGI>.
=cut
sub alias {
return (
fastcgi => "FastCGI",
)
}
=head2 print_help
Prints out help for the package using pod2usage.
If the user specified --help, prints a brief usage message
If the user specified --man, prints out a manpage
=cut
sub print_help {
my $self = shift;
my $msg = shift;
$self->{'help'} = 1
if $msg && !( $self->{'help'} || $self->{'man'} );
my %opts = (
-exitval => $msg? 1: 0,
-input => $self->filename,
-verbose => 99,
$msg? (-message => $msg): (),
);
# Option handling
pod2usage(
%opts,
-sections => 'NAME|SYNOPSIS',
) if $self->{help};
pod2usage(
%opts,
-sections => '!METHODS',
) if $self->{man};
}
1;
|