| 1 | # ABSTRACT: App::Spec Plugin for meta functions | ||||||||||||||||||
| 2 | 6 | ▶ | use strict; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 3 | 6 | ▶ | use warnings; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 4 | package App::Spec::Plugin::Meta; | ||||||||||||||||||
| 5 | 6 | our $VERSION = 'v0.15.1'; # TRIAL VERSION | |||||||||||||||||
| 6 | |||||||||||||||||||
| 7 | 6 | ▶ | use List::Util qw/ any /; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 8 | |||||||||||||||||||
| 9 | 6 | ▶ | use Moo; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 10 | 6 | with 'App::Spec::Role::Plugin::Subcommand'; | |||||||||||||||||
| 11 | |||||||||||||||||||
| 12 | 6 | my $yaml = do { local $/; <DATA> }; | |||||||||||||||||
| 13 | |||||||||||||||||||
| 14 | 37 | ▶ | sub install_subcommands { | ||||||||||||||||
|
Subroutine
install_subcommands: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||
| 15 | 37 | my ($class, %args) = @_; | |||||||||||||||||
| 16 | 37 | my $parent = $args{spec}; | |||||||||||||||||
| 17 | 37 | my $appspec = App::Spec::Subcommand->read(\$yaml); | |||||||||||||||||
| 18 | 37 | return $appspec; | |||||||||||||||||
| 19 | } | ||||||||||||||||||
| 20 | |||||||||||||||||||
| 21 | 0 | ▶ | sub cmd_self_completion { | ||||||||||||||||
|
Subroutine
cmd_self_completion: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||
| 22 | 0 | my ($self, $run) = @_; | |||||||||||||||||
| 23 | 0 | my $options = $run->options; | |||||||||||||||||
| 24 | 0 | ▶ | my $shell = $options->{zsh} ? "zsh" : $options->{bash} ? "bash" : $options->{fish} ? "fish" : ''; | ||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||
| 25 | 0 | ▶ | unless ($shell) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 26 | 0 | my $ppid = getppid(); | |||||||||||||||||
| 27 | 0 | chomp($shell = `ps --no-headers -o cmd $ppid`); | |||||||||||||||||
| 28 | 0 | $shell =~ s/.*\W(\w*sh).*$/$1/; #handling case of '-zsh' or '/bin/bash' | |||||||||||||||||
| 29 | #or bash -i -rs | ||||||||||||||||||
| 30 | } | ||||||||||||||||||
| 31 | 0 | ▶ | unless (any { $_ eq $shell } qw/ bash zsh fish / ) { | ||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||
| 32 | 0 | die "Specify which shell, '$shell' not supported"; | |||||||||||||||||
| 33 | } | ||||||||||||||||||
| 34 | 0 | my $spec = $run->spec; | |||||||||||||||||
| 35 | 0 | my $completion = $spec->generate_completion( | |||||||||||||||||
| 36 | shell => $shell, | ||||||||||||||||||
| 37 | ); | ||||||||||||||||||
| 38 | 0 | $run->out($completion); | |||||||||||||||||
| 39 | } | ||||||||||||||||||
| 40 | |||||||||||||||||||
| 41 | 0 | ▶ | sub cmd_self_pod { | ||||||||||||||||
|
Subroutine
cmd_self_pod: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||
| 42 | 0 | my ($self, $run) = @_; | |||||||||||||||||
| 43 | 0 | my $spec = $run->spec; | |||||||||||||||||
| 44 | |||||||||||||||||||
| 45 | 0 | require App::Spec::Pod; | |||||||||||||||||
| 46 | 0 | my $generator = App::Spec::Pod->new( | |||||||||||||||||
| 47 | spec => $self, | ||||||||||||||||||
| 48 | ); | ||||||||||||||||||
| 49 | 0 | my $pod = $generator->generate; | |||||||||||||||||
| 50 | |||||||||||||||||||
| 51 | 0 | $run->out($pod); | |||||||||||||||||
| 52 | } | ||||||||||||||||||
| 53 | |||||||||||||||||||
| 54 | 6 | 1; | |||||||||||||||||
| 55 | |||||||||||||||||||
| 56 | =pod | ||||||||||||||||||
| 57 | |||||||||||||||||||
| 58 | =head1 NAME | ||||||||||||||||||
| 59 | |||||||||||||||||||
| 60 | App::Spec::Plugin::Meta - App::Spec Plugin for meta functions | ||||||||||||||||||
| 61 | |||||||||||||||||||
| 62 | =head1 DESCRIPTION | ||||||||||||||||||
| 63 | |||||||||||||||||||
| 64 | This plugin is enabled in L<App::Spec> by default. | ||||||||||||||||||
| 65 | |||||||||||||||||||
| 66 | It adds the following commands to your app: | ||||||||||||||||||
| 67 | |||||||||||||||||||
| 68 | % app meta completion generate | ||||||||||||||||||
| 69 | % app meta pod generate | ||||||||||||||||||
| 70 | |||||||||||||||||||
| 71 | =head1 METHODS | ||||||||||||||||||
| 72 | |||||||||||||||||||
| 73 | =over 4 | ||||||||||||||||||
| 74 | |||||||||||||||||||
| 75 | =item cmd_self_completion | ||||||||||||||||||
| 76 | |||||||||||||||||||
| 77 | This is called by C<app meta completion generate> | ||||||||||||||||||
| 78 | |||||||||||||||||||
| 79 | =item cmd_self_pod | ||||||||||||||||||
| 80 | |||||||||||||||||||
| 81 | This is called by C<app meta pod generate> | ||||||||||||||||||
| 82 | |||||||||||||||||||
| 83 | =item install_subcommands | ||||||||||||||||||
| 84 | |||||||||||||||||||
| 85 | See L<App::Spec::Role::Plugin::Subcommand#install_subcommands> | ||||||||||||||||||
| 86 | |||||||||||||||||||
| 87 | =back | ||||||||||||||||||
| 88 | |||||||||||||||||||
| 89 | =cut | ||||||||||||||||||
| 90 | |||||||||||||||||||
| 91 | __DATA__ | ||||||||||||||||||