| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Taskwarrior::Kusarigama::Plugin; |
|
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:YANICK'; |
|
3
|
|
|
|
|
|
|
# ABSTRACT: Base class for Kusarigama plugins |
|
4
|
|
|
|
|
|
|
$Taskwarrior::Kusarigama::Plugin::VERSION = '0.11.0'; |
|
5
|
|
|
|
|
|
|
|
|
6
|
4
|
|
|
4
|
|
2227
|
use 5.10.0; |
|
|
4
|
|
|
|
|
16
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
4
|
|
|
4
|
|
25
|
use strict; |
|
|
4
|
|
|
|
|
7
|
|
|
|
4
|
|
|
|
|
94
|
|
|
9
|
4
|
|
|
4
|
|
21
|
use warnings; |
|
|
4
|
|
|
|
|
9
|
|
|
|
4
|
|
|
|
|
106
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
4
|
|
|
4
|
|
22
|
use Moo; |
|
|
4
|
|
|
|
|
15
|
|
|
|
4
|
|
|
|
|
22
|
|
|
12
|
4
|
|
|
4
|
|
2171
|
use MooseX::MungeHas; |
|
|
4
|
|
|
|
|
7553
|
|
|
|
4
|
|
|
|
|
25
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has tw => ( |
|
16
|
|
|
|
|
|
|
is => 'ro', |
|
17
|
|
|
|
|
|
|
required => 1, |
|
18
|
|
|
|
|
|
|
handles => 'Taskwarrior::Kusarigama::Core', |
|
19
|
|
|
|
|
|
|
); |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
has name => sub { |
|
23
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
24
|
0
|
|
|
|
|
|
my $name = ref $self; |
|
25
|
0
|
|
0
|
|
|
|
return $name =~ s/Taskwarrior::Kusarigama::Plugin:://r || "+$name"; |
|
26
|
|
|
|
|
|
|
}; |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# TODO implement an uninstall counterpart |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub setup { |
|
32
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
33
|
|
|
|
|
|
|
|
|
34
|
0
|
0
|
|
|
|
|
if( $self->can('custom_uda') ) { |
|
35
|
0
|
|
|
|
|
|
say "Setting up custom UDAs..."; |
|
36
|
0
|
|
|
|
|
|
my $uda = $self->custom_uda; |
|
37
|
0
|
|
|
|
|
|
for my $name ( keys %$uda ) { |
|
38
|
0
|
|
|
|
|
|
my $c = "uda.$name"; |
|
39
|
0
|
|
|
|
|
|
say $name; |
|
40
|
|
|
|
|
|
|
say "UDA already defined, skipping" and next |
|
41
|
0
|
0
|
0
|
|
|
|
if $self->tw->config->{uda}{$name}; |
|
42
|
0
|
|
|
|
|
|
system 'task', 'config', $c . '.label', $uda->{$name}; |
|
43
|
0
|
|
|
|
|
|
system 'task', 'config', $c . '.type', 'string'; |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
0
|
0
|
|
|
|
|
if ( $self->DOES('Taskwarrior::Kusarigama::Hook::OnCommand') ) { |
|
48
|
0
|
|
|
|
|
|
my $name = $self->command_name; |
|
49
|
0
|
0
|
|
|
|
|
if ( $self->tw->config->{report}{$name} ) { |
|
50
|
0
|
|
|
|
|
|
say "report '$name' already exist, skipping"; |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
else { |
|
53
|
0
|
|
|
|
|
|
system 'task', 'config', 'report.'.$name.'.columns', 'id'; |
|
54
|
0
|
|
|
|
|
|
system 'task', 'config', 'report.'.$name.'.description', |
|
55
|
|
|
|
|
|
|
'pseudo-report for command'; |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
__END__ |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=pod |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=encoding UTF-8 |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 NAME |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Taskwarrior::Kusarigama::Plugin - Base class for Kusarigama plugins |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 VERSION |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
version 0.11.0 |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
package Taskwarrior::Kusarigama::Plugin::Foo; |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
use Moo; |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
extends 'Taskwarrior::Kusarigama::Plugin'; |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
with 'Taskwarrior::Kusarigama::Hook::OnLaunch'; |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub on_launch { ... }' |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
1; |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Base class for all Taskwarrior::Kusarigama plugins. |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head2 METHODS |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head3 new |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
my $plugin = Taskwarrior::Kusarigama::Plugin->new( |
|
101
|
|
|
|
|
|
|
tw => $tw, |
|
102
|
|
|
|
|
|
|
); |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Constructor. Supports the following arguments. |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=over |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=item tw |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Associated L<Taskwarrior::Kusarigama::Hook> object. |
|
111
|
|
|
|
|
|
|
Required. |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=item name |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Plugin name. If not provided, it is derived from the package |
|
116
|
|
|
|
|
|
|
name. |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=back |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head3 tw |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Returns the associated L<Taskwarrior::Kusarigama::Hook> |
|
123
|
|
|
|
|
|
|
object. |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
All the L<Taskwarrior::Kusarigama::Core> methods |
|
126
|
|
|
|
|
|
|
are made available to the plugin object via this attribute. |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head3 name |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Returns the plugin name. |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head3 setup |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Method used by C<task-kusarigama> to set up the plugin. |
|
135
|
|
|
|
|
|
|
If the plugin defines any UDAs, they will be created. |
|
136
|
|
|
|
|
|
|
Likewise, if the plugin is a custom command, a dummy |
|
137
|
|
|
|
|
|
|
report will be created in the taskwarrior configuration |
|
138
|
|
|
|
|
|
|
to allow it to be used. |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head1 AUTHOR |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
Yanick Champoux <yanick@cpan.org> |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
This software is copyright (c) 2018, 2017 by Yanick Champoux. |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
149
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=cut |