line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Sietima::CmdLine; |
2
|
1
|
|
|
1
|
|
13073
|
use Moo; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
8
|
|
3
|
1
|
|
|
1
|
|
371
|
use Sietima::Policy; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
4
|
1
|
|
|
1
|
|
7
|
use Sietima::Types qw(SietimaObj); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
12
|
|
5
|
1
|
|
|
1
|
|
579
|
use Types::Standard qw(HashRef); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
9
|
|
6
|
1
|
|
|
1
|
|
789
|
use Sietima; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
21
|
|
7
|
1
|
|
|
1
|
|
486
|
use App::Spec; |
|
1
|
|
|
|
|
71323
|
|
|
1
|
|
|
|
|
40
|
|
8
|
1
|
|
|
1
|
|
500
|
use Sietima::Runner; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
42
|
|
9
|
1
|
|
|
1
|
|
8
|
use namespace::clean; |
|
1
|
|
|
|
|
37
|
|
|
1
|
|
|
|
|
14
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '1.0.4'; # VERSION |
12
|
|
|
|
|
|
|
# ABSTRACT: run Sietima as a command-line application |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has sietima => ( |
16
|
|
|
|
|
|
|
is => 'ro', |
17
|
|
|
|
|
|
|
required => 1, |
18
|
|
|
|
|
|
|
isa => SietimaObj, |
19
|
|
|
|
|
|
|
); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
has extra_spec => ( |
23
|
|
|
|
|
|
|
is => 'ro', |
24
|
|
|
|
|
|
|
isa => HashRef, |
25
|
|
|
|
|
|
|
default => sub { +{} }, |
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
4
|
|
|
4
|
0
|
31339
|
sub BUILDARGS($class,@args) { |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
9
|
|
30
|
4
|
|
|
|
|
31
|
my $args = $class->next::method(@args); |
31
|
4
|
|
66
|
|
|
121
|
$args->{sietima} //= do { |
32
|
3
|
|
100
|
|
|
16
|
my $traits = delete $args->{traits} // []; |
33
|
3
|
|
50
|
|
|
13
|
my $constructor_args = delete $args->{args} // {}; |
34
|
3
|
|
|
|
|
18
|
Sietima->with_traits($traits->@*)->new($constructor_args); |
35
|
|
|
|
|
|
|
}; |
36
|
4
|
|
|
|
|
7677
|
return $args; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
has app_spec => ( |
41
|
|
|
|
|
|
|
is => 'lazy', |
42
|
|
|
|
|
|
|
init_arg => undef, |
43
|
|
|
|
|
|
|
); |
44
|
|
|
|
|
|
|
|
45
|
2
|
|
|
2
|
|
1744
|
sub _build_app_spec($self) { |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
4
|
|
46
|
2
|
|
|
|
|
18
|
my $spec_data = $self->sietima->command_line_spec(); |
47
|
|
|
|
|
|
|
|
48
|
2
|
|
|
|
|
33
|
return App::Spec->read({ |
49
|
|
|
|
|
|
|
$spec_data->%*, |
50
|
|
|
|
|
|
|
$self->extra_spec->%*, |
51
|
|
|
|
|
|
|
}); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
has runner => ( |
56
|
|
|
|
|
|
|
is => 'lazy', |
57
|
|
|
|
|
|
|
init_arg => undef, |
58
|
|
|
|
|
|
|
handles => [qw(run)], |
59
|
|
|
|
|
|
|
); |
60
|
|
|
|
|
|
|
|
61
|
1
|
|
|
1
|
|
47815
|
sub _build_runner($self) { |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
3
|
|
62
|
1
|
|
|
|
|
19
|
return Sietima::Runner->new({ |
63
|
|
|
|
|
|
|
spec => $self->app_spec, |
64
|
|
|
|
|
|
|
cmd => $self->sietima, |
65
|
|
|
|
|
|
|
# App::Spec 0.005 really wants a class name |
66
|
|
|
|
|
|
|
class => ref($self->sietima), |
67
|
|
|
|
|
|
|
}); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
1; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
__END__ |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=pod |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=encoding UTF-8 |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 NAME |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Sietima::CmdLine - run Sietima as a command-line application |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 VERSION |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
version 1.0.4 |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 SYNOPSIS |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
use Sietima::CmdLine; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Sietima::CmdLine->new({ |
91
|
|
|
|
|
|
|
traits => [qw(SubjectTag)], |
92
|
|
|
|
|
|
|
args => { |
93
|
|
|
|
|
|
|
return_path => 'list@example.net', |
94
|
|
|
|
|
|
|
subject_tag => 'Test', |
95
|
|
|
|
|
|
|
subscribers => \@addresses, |
96
|
|
|
|
|
|
|
})->run; |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 DESCRIPTION |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
This class simplifies the creation of a L<< C<Sietima> >> object, and |
101
|
|
|
|
|
|
|
uses L<< C<App::Spec> >> to provide a command-line interface to it. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head2 C<sietima> |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Required, an instance of L<< C<Sietima> >>. You can either construct |
108
|
|
|
|
|
|
|
it yourself, or use the L<simplified building provided by the |
109
|
|
|
|
|
|
|
constructor|/new>. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head2 C<extra_spec> |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Optional hashref. Used inside L<< /C<app_spec> >>. If you're not |
114
|
|
|
|
|
|
|
familiar with L<< C<App::Spec> >>, you probably don't want to touch |
115
|
|
|
|
|
|
|
this. |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 METHODS |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head2 C<new> |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
my $cmdline = Sietima::CmdLine->new({ |
122
|
|
|
|
|
|
|
sietima => Sietima->with_traits(qw(SubjectTag))->new({ |
123
|
|
|
|
|
|
|
return_path => 'list@example.net', |
124
|
|
|
|
|
|
|
subject_tag => 'Test', |
125
|
|
|
|
|
|
|
subscribers => \@addresses, |
126
|
|
|
|
|
|
|
}), |
127
|
|
|
|
|
|
|
}); |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
my $cmdline = Sietima::CmdLine->new({ |
130
|
|
|
|
|
|
|
traits => [qw(SubjectTag)], |
131
|
|
|
|
|
|
|
args => { |
132
|
|
|
|
|
|
|
return_path => 'list@example.net', |
133
|
|
|
|
|
|
|
subject_tag => 'Test', |
134
|
|
|
|
|
|
|
subscribers => \@addresses, |
135
|
|
|
|
|
|
|
}); |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
The constructor. In alternative to passing a L<< C<Sietima> >> |
138
|
|
|
|
|
|
|
instance, you can pass C<traits> and C<args>, and the instance will be |
139
|
|
|
|
|
|
|
built for you. The two calls above are equivalent. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head2 C<app_spec> |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Returns an instance of L<< C<App::Spec> >>, built from the |
144
|
|
|
|
|
|
|
specification returned by calling L<< |
145
|
|
|
|
|
|
|
C<command_line_spec>|Sietima/command_line_spec >> on the L<< |
146
|
|
|
|
|
|
|
/C<sietima> >> object, modified by the L<< /C<extra_spec> >>. This |
147
|
|
|
|
|
|
|
method, and the C<extra_spec> attribute, are probably only interesting |
148
|
|
|
|
|
|
|
to people who are doing weird extensions. |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head2 C<runner> |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
Returns an instance of L<< C<Sietima::Runner> >>, built from the L<< |
153
|
|
|
|
|
|
|
/C<app_spec> >>. |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=head2 C<run> |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Delegates to the L<< /C<runner> >>'s L<< C<run>|App::Spec::Run/run >> method. |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
Parser the command line arguments from C<@ARGV> and executes the |
160
|
|
|
|
|
|
|
appropriate action. |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=for Pod::Coverage BUILDARGS |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=head1 AUTHOR |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
Gianni Ceccarelli <dakkar@thenautilus.net> |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
This software is copyright (c) 2017 by Gianni Ceccarelli <dakkar@thenautilus.net>. |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
173
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=cut |