line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Taskwarrior::Kusarigama::Hook::OnCommand; |
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:YANICK'; |
3
|
|
|
|
|
|
|
#ABSTRACT: Role for plugins implementing custom commands |
4
|
|
|
|
|
|
|
$Taskwarrior::Kusarigama::Hook::OnCommand::VERSION = '0.11.0'; |
5
|
1
|
|
|
1
|
|
607
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
31
|
|
6
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
27
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
6
|
use Moo::Role; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
7
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has command_name => ( |
11
|
|
|
|
|
|
|
is => 'ro', |
12
|
|
|
|
|
|
|
default => sub { |
13
|
|
|
|
|
|
|
lc( |
14
|
|
|
|
|
|
|
( lcfirst ref($_[0]) =~ s/^.*::Command:://r ) |
15
|
|
|
|
|
|
|
=~ s/(?=[A-Z])/-/gr |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
}, |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
requires 'on_command'; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
1; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
__END__ |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=pod |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=encoding UTF-8 |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 NAME |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
Taskwarrior::Kusarigama::Hook::OnCommand - Role for plugins implementing custom commands |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 VERSION |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
version 0.11.0 |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 SYNOPSIS |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
package Taskwarrior::Kusarigama::Plugin::Command::Foo; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
use Moo; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
extends 'Taskwarrior::Kusarigama::Hook'; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
with 'Taskwarrior::Kusarigama::Hook::OnCommand'; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub on_command { |
49
|
|
|
|
|
|
|
say "running foo"; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
1; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 DESCRIPTION |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Role consumed by plugins implementing a custom command. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Requires that a C<on_command> is implemented. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
By default, the command name is the name of the package minus |
61
|
|
|
|
|
|
|
its |
62
|
|
|
|
|
|
|
C<Taskwarrior::Kusarigama::Plugin::Command::> prefix, |
63
|
|
|
|
|
|
|
but it can be modified via the C<command_name> attribute. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
package MyCustom::Command; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
use Moo; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
extends 'Taskwarrior::Kusarigama::Hook'; |
70
|
|
|
|
|
|
|
with 'Taskwarrior::Kusarigama::Hook::OnCommand'; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
# will intercept `task custom-command` |
73
|
|
|
|
|
|
|
has '+command_name' => ( |
74
|
|
|
|
|
|
|
default => sub { return 'custom-command' }, |
75
|
|
|
|
|
|
|
); |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub on_command { ... }; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 AUTHOR |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Yanick Champoux <yanick@cpan.org> |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
This software is copyright (c) 2018, 2017 by Yanick Champoux. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
88
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=cut |