/usr/share/perl5/Reply/App.pm is in libreply-perl 0.38-1.
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 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 | package Reply::App;
our $AUTHORITY = 'cpan:DOY';
$Reply::App::VERSION = '0.38';
use strict;
use warnings;
# ABSTRACT: command line app runner for Reply
use Getopt::Long 2.36 'GetOptionsFromArray';
use Reply;
use Reply::Config;
sub new { bless {}, shift }
sub run {
my $self = shift;
my @argv = @_;
Getopt::Long::Configure("gnu_getopt");
my $cfgfile = '.replyrc';
my $exitcode;
my (@modules, @script_lines, @files);
my $parsed = GetOptionsFromArray(
\@argv,
'cfg:s' => \$cfgfile,
'l|lib' => sub { unshift @INC, 'lib' },
'b|blib' => sub { unshift @INC, 'blib/lib', 'blib/arch' },
'I:s@' => sub { unshift @INC, $_[1] },
'M:s@' => \@modules,
'e:s@' => \@script_lines,
'version' => sub { $exitcode = 0; version() },
'help' => sub { $exitcode = 0; usage() },
);
@files = @argv;
for my $file (@files) {
if (!stat $file) {
die "Can't read $file: $!";
}
}
if (!$parsed) {
usage(1);
$exitcode = 1;
}
return $exitcode if defined $exitcode;
my $cfg = Reply::Config->new(file => $cfgfile);
my %args = (config => $cfg);
my $file = $cfg->file;
if (!-e $file) {
print("$file not found. Generating a default...\n");
unless ($self->generate_default_config($file)) {
%args = ();
}
}
my $reply = Reply->new(%args);
$reply->step("use $_") for @modules;
$reply->step($_, 1) for @script_lines;
$reply->step('do "' . quotemeta($_) . '"', 1) for @files;
$reply->run;
return 0;
}
sub generate_default_config {
my $self = shift;
my ($file) = @_;
if (open my $fh, '>', $file) {
my $contents = do {
local $/;
<DATA>
};
$contents =~ s/use 5.XXX/use $]/;
print $fh $contents;
close $fh;
return 1;
}
else {
warn "Couldn't write to $file";
return 0;
}
}
sub usage {
my $fh = $_[0] ? *STDERR : *STDOUT;
print $fh " reply [-lb] [-I dir] [-M mod] [--version] [--help] [--cfg file]\n";
}
sub version {
my $fh = $_[0] ? *STDERR : *STDOUT;
print $fh "Reply version $Reply::VERSION\n";
}
1;
=pod
=encoding UTF-8
=head1 NAME
Reply::App - command line app runner for Reply
=head1 VERSION
version 0.38
=head1 SYNOPSIS
use Reply::App;
exit(Reply::App->new->run(@ARGV));
=head1 DESCRIPTION
This module encapsulates the various bits of functionality related to running
L<Reply> as a command line application.
=head1 METHODS
=head2 new
Returns a new Reply::App instance. Takes no arguments.
=head2 run(@argv)
Parses the argument list given (typically from @ARGV), along with the user's configuration file, and attempts to start a Reply shell. A default configuration file will be generated for the user if none exists.
=head2 generate_default_config($file)
Generates default configuration file as per specified destination.
=head2 usage($exitcode)
Prints usage information to the screen. If C<$exitcode> is 0, it will be
printed to C<STDOUT>, otherwise it will be printed to C<STDERR>.
=head2 version($exitcode)
Prints version information to the screen. If C<$exitcode> is 0, it will be
printed to C<STDOUT>, otherwise it will be printed to C<STDERR>.
=head1 AUTHOR
Jesse Luehrs <doy@tozt.net>
=head1 COPYRIGHT AND LICENSE
This software is Copyright (c) 2015 by Jesse Luehrs.
This is free software, licensed under:
The MIT (X11) License
=cut
__DATA__
script_line1 = use strict
script_line2 = use warnings
script_line3 = use 5.XXX
[Interrupt]
[FancyPrompt]
[DataDumper]
[Colors]
[ReadLine]
[Hints]
[Packages]
[LexicalPersistence]
[ResultCache]
[Autocomplete::Packages]
[Autocomplete::Lexicals]
[Autocomplete::Functions]
[Autocomplete::Globals]
[Autocomplete::Methods]
[Autocomplete::Commands]
|