line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use strict; |
3
|
1
|
|
|
1
|
|
113086
|
# IFUNBUILT |
|
1
|
|
|
|
|
11
|
|
|
1
|
|
|
|
|
294
|
|
4
|
|
|
|
|
|
|
# use warnings; |
5
|
|
|
|
|
|
|
# END IFUNBUILT |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY |
8
|
|
|
|
|
|
|
our $DATE = '2021-12-01'; # DATE |
9
|
|
|
|
|
|
|
our $DIST = 'Perinci-CmdLine-Any'; # DIST |
10
|
|
|
|
|
|
|
our $VERSION = '0.153'; # VERSION |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my %Opts = ( |
13
|
|
|
|
|
|
|
-prefer_lite => 1, |
14
|
|
|
|
|
|
|
); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my ($class, %args) = @_; |
17
|
|
|
|
|
|
|
$Opts{$_} = $args{$_} for keys %args; |
18
|
1
|
|
|
1
|
|
8
|
} |
19
|
1
|
|
|
|
|
1719
|
|
20
|
|
|
|
|
|
|
my $class = shift; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
my @mods; |
23
|
1
|
|
|
1
|
0
|
2733
|
my $env = $ENV{PERINCI_CMDLINE_ANY}; |
24
|
|
|
|
|
|
|
if ($env) { |
25
|
1
|
|
|
|
|
2
|
if ($env eq 'classic') { |
26
|
1
|
|
|
|
|
3
|
$env = 'Perinci::CmdLine::Classic'; |
27
|
1
|
50
|
|
|
|
5
|
} elsif ($env eq 'lite') { |
|
|
50
|
|
|
|
|
|
28
|
0
|
0
|
|
|
|
0
|
$env = 'Perinci::CmdLine::Lite'; |
|
|
0
|
|
|
|
|
|
29
|
0
|
|
|
|
|
0
|
} |
30
|
|
|
|
|
|
|
@mods = ($env); |
31
|
0
|
|
|
|
|
0
|
} elsif ($Opts{-prefer_lite}) { |
32
|
|
|
|
|
|
|
@mods = qw(Perinci::CmdLine::Lite Perinci::CmdLine::Classic); |
33
|
0
|
|
|
|
|
0
|
} else { |
34
|
|
|
|
|
|
|
@mods = qw(Perinci::CmdLine::Classic Perinci::CmdLine::Lite); |
35
|
1
|
|
|
|
|
3
|
} |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
0
|
for my $i (1..@mods) { |
38
|
|
|
|
|
|
|
my $mod = $mods[$i-1]; |
39
|
|
|
|
|
|
|
my $modpm = $mod; $modpm =~ s!::!/!g; $modpm .= ".pm"; |
40
|
1
|
|
|
|
|
4
|
if ($i == @mods) { |
41
|
1
|
|
|
|
|
3
|
require $modpm; |
42
|
1
|
|
|
|
|
2
|
return $mod->new(@_); |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
2
|
|
43
|
1
|
50
|
|
|
|
4
|
} else { |
44
|
0
|
|
|
|
|
0
|
my $res; |
45
|
0
|
|
|
|
|
0
|
eval { |
46
|
|
|
|
|
|
|
require $modpm; |
47
|
1
|
|
|
|
|
1
|
$res = $mod->new(@_); |
48
|
1
|
|
|
|
|
2
|
}; |
49
|
1
|
|
|
|
|
1414
|
if ($@) { |
50
|
1
|
|
|
|
|
57297
|
next; |
51
|
|
|
|
|
|
|
} else { |
52
|
1
|
50
|
|
|
|
21137
|
return $res; |
53
|
0
|
|
|
|
|
0
|
} |
54
|
|
|
|
|
|
|
} |
55
|
1
|
|
|
|
|
9
|
} |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
1; |
59
|
|
|
|
|
|
|
# ABSTRACT: Choose Perinci::CmdLine implementation (::Lite or ::Classic) |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=pod |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=encoding UTF-8 |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 NAME |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Perinci::CmdLine::Any - Choose Perinci::CmdLine implementation (::Lite or ::Classic) |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 VERSION |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
This document describes version 0.153 of Perinci::CmdLine::Any (from Perl distribution Perinci-CmdLine-Any), released on 2021-12-01. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 SYNOPSIS |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
In your command-line script (this will pick ::Lite first): |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
#!perl |
79
|
|
|
|
|
|
|
use Perinci::CmdLine::Any; |
80
|
|
|
|
|
|
|
Perinci::CmdLine::Any->new(url => '/Package/func')->run; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
In your command-line script (this will pick ::Classic first, and falls back to |
83
|
|
|
|
|
|
|
::Lite): |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
#!perl |
86
|
|
|
|
|
|
|
use Perinci::CmdLine::Any -prefer_lite=>0; |
87
|
|
|
|
|
|
|
Perinci::CmdLine::Any->new(url => '/Package/func')->run; |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 DESCRIPTION |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
This module lets you use L<Perinci::CmdLine::Lite> or |
92
|
|
|
|
|
|
|
L<Perinci::CmdLine::Classic>. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
If you want to force using a specific class, you can set the |
95
|
|
|
|
|
|
|
C<PERINCI_CMDLINE_ANY> environment variable, e.g. the command below will only |
96
|
|
|
|
|
|
|
try to use Perinci::CmdLine::Classic: |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
% PERINCI_CMDLINE_ANY=Perinci::CmdLine::Classic yourapp.pl |
99
|
|
|
|
|
|
|
% PERINCI_CMDLINE_ANY=classic yourapp.pl |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
If you want to prefer to Perinci::CmdLine::Classic (but user will still be able |
102
|
|
|
|
|
|
|
to override using C<PERINCI_CMDLINE_ANY>): |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
use Perinci::CmdLine::Any -prefer_lite => 0; |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=for Pod::Coverage ^(new)$ |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 ENVIRONMENT |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head2 PERINCI_CMDLINE_ANY => str |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Either specify module name, or C<lite> or C<classic>. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 HOMEPAGE |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Please visit the project's homepage at L<https://metacpan.org/release/Perinci-CmdLine-Any>. |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 SOURCE |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Source repository is at L<https://github.com/perlancar/perl-Perinci-CmdLine-Any>. |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 SEE ALSO |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
L<Perinci::CmdLine::Lite>, L<Perinci::CmdLine::Classic> |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Another alternative backend, but not available through Perinci::CmdLine::Any |
127
|
|
|
|
|
|
|
since it works by generating script instead: L<Perinci::CmdLine::Inline> |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head1 AUTHOR |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
perlancar <perlancar@cpan.org> |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head1 CONTRIBUTOR |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=for stopwords Steven Haryanto |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Steven Haryanto <stevenharyanto@gmail.com> |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head1 CONTRIBUTING |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
To contribute, you can send patches by email/via RT, or send pull requests on |
143
|
|
|
|
|
|
|
GitHub. |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Most of the time, you don't need to build the distribution yourself. You can |
146
|
|
|
|
|
|
|
simply modify the code, then test via: |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
% prove -l |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
If you want to build the distribution (e.g. to try to install it locally on your |
151
|
|
|
|
|
|
|
system), you can install L<Dist::Zilla>, |
152
|
|
|
|
|
|
|
L<Dist::Zilla::PluginBundle::Author::PERLANCAR>, and sometimes one or two other |
153
|
|
|
|
|
|
|
Dist::Zilla plugin and/or Pod::Weaver::Plugin. Any additional steps required |
154
|
|
|
|
|
|
|
beyond that are considered a bug and can be reported to me. |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
This software is copyright (c) 2021, 2019, 2017, 2016, 2015, 2014 by perlancar <perlancar@cpan.org>. |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
161
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head1 BUGS |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
Please report any bugs or feature requests on the bugtracker website L<https://rt.cpan.org/Public/Dist/Display.html?Name=Perinci-CmdLine-Any> |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
When submitting a bug or request, please include a test-file or a |
168
|
|
|
|
|
|
|
patch to an existing test-file that illustrates the bug or desired |
169
|
|
|
|
|
|
|
feature. |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=cut |