| 1 | package App::BCSSH::Command::help; | ||||||||||
| 2 | 1 | ▶ | use strictures 1; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | |||||||||||
| 4 | 1 | ▶ | use Module::Reader qw(:all); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | ▶ | use File::Temp (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 1 | ▶ | use File::Spec; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | ▶ | use Pod::Perldoc; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 1 | ▶ | use Pod::Perldoc::ToMan; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 1 | ▶ | use App::BCSSH::Util qw(command_to_package package_to_command); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 1 | ▶ | use App::BCSSH::Command::commands; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | 0 | ▶ | sub new { bless { command => $_[1] }, $_[0] } | ||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 13 | |||||||||||
| 14 | 0 | ▶ | sub run { | ||||||||
|
Subroutine
run: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 15 | 0 | my $self = shift; | |||||||||
| 16 | 0 | my $command = $self->{command}; | |||||||||
| 17 | 0 | ▶ | if ($command) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 18 | 0 | $self->help_for_package(command_to_package($command)); | |||||||||
| 19 | } | ||||||||||
| 20 | else { | ||||||||||
| 21 | 0 | $self->help_for_package('App::BCSSH'); | |||||||||
| 22 | } | ||||||||||
| 23 | } | ||||||||||
| 24 | |||||||||||
| 25 | 0 | ▶ | sub help_for_package { | ||||||||
|
Subroutine
help_for_package: not called CC=3 SCAR=22.7
Pod
undocumented
| |||||||||||
| 26 | 0 | my $self = shift; | |||||||||
| 27 | 0 | my $package = shift; | |||||||||
| 28 | 0 | my $pod = module_content($package, { found => \%INC }); | |||||||||
| 29 | 0 | my $command = package_to_command($package); | |||||||||
| 30 | |||||||||||
| 31 | # perldoc will try to drop privs anyway, so do it ourselves so the | ||||||||||
| 32 | # temp file has the correct owner | ||||||||||
| 33 | 0 | Pod::Perldoc->new->drop_privs_maybe; | |||||||||
| 34 | |||||||||||
| 35 | 0 | ▶ | my $pod_name = $command ? "bcssh-$command" : $package; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 36 | 0 | my $pod_file = $pod_name; | |||||||||
| 37 | 0 | $pod_file =~ s/::/-/g; | |||||||||
| 38 | 0 | ▶ | my $section = $command ? 1 : 3; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 39 | 0 | my $tmpdir = File::Temp->newdir( TMPDIR => 1 ); | |||||||||
| 40 | 0 | my $out_file = File::Spec->catfile($tmpdir, $pod_file); | |||||||||
| 41 | 0 | open my $out, '>', $out_file; | |||||||||
| 42 | 0 | print {$out} $pod; | |||||||||
| 43 | 0 | close $out; | |||||||||
| 44 | { | ||||||||||
| 45 | 0 | ▶ | no warnings qw(redefine once); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
| |||||||||||
| 46 | # fix width handling | ||||||||||
| 47 | 0 | *Pod::Perldoc::ToMan::is_linux = sub () { 1 }; | |||||||||
| 48 | # silence groff warning | ||||||||||
| 49 | 0 | ▶ | *Pod::Perldoc::ToMan::warn = sub {}; | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 50 | # fix option passing | ||||||||||
| 51 | 0 | ▶ | *Pod::Perldoc::ToMan::_get_podman_switches = sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 52 | 0 | my $self = shift; | |||||||||
| 53 | 0 | return map {; $_ => $self->{$_} } grep !m/^_/s, keys %$self; | |||||||||
| 54 | 0 | }; | |||||||||
| 55 | } | ||||||||||
| 56 | @ARGV = ( | ||||||||||
| 57 | 0 | -o => 'Man', | |||||||||
| 58 | -w => "name:$pod_name", | ||||||||||
| 59 | -w => "section:$section", | ||||||||||
| 60 | -w => 'center:', | ||||||||||
| 61 | '-F' => $out_file, | ||||||||||
| 62 | ); | ||||||||||
| 63 | 0 | exit Pod::Perldoc->run; | |||||||||
| 64 | } | ||||||||||
| 65 | |||||||||||
| 66 | 1 | 1; | |||||||||
| 67 | |||||||||||
| 68 | __END__ | ||||||||||