line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Taskwarrior::Kusarigama::Plugin::ProjectDefaults; |
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:YANICK'; |
3
|
|
|
|
|
|
|
# ABSTRACT: assign project-level defaults when creating tasks |
4
|
|
|
|
|
|
|
$Taskwarrior::Kusarigama::Plugin::ProjectDefaults::VERSION = '0.12.0'; |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
145959
|
use 5.10.0; |
|
1
|
|
|
|
|
8
|
|
7
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
17
|
|
8
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
543
|
use JSON qw/ from_json /; |
|
1
|
|
|
|
|
8774
|
|
|
1
|
|
|
|
|
5
|
|
11
|
1
|
|
|
1
|
|
522
|
use Hash::Merge qw/ merge /; |
|
1
|
|
|
|
|
7643
|
|
|
1
|
|
|
|
|
50
|
|
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
432
|
use Moo; |
|
1
|
|
|
|
|
7741
|
|
|
1
|
|
|
|
|
5
|
|
14
|
1
|
|
|
1
|
|
1585
|
use MooseX::MungeHas; |
|
1
|
|
|
|
|
3220
|
|
|
1
|
|
|
|
|
6
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
extends 'Taskwarrior::Kusarigama::Plugin'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
with 'Taskwarrior::Kusarigama::Hook::OnAdd'; |
19
|
|
|
|
|
|
|
|
20
|
1
|
|
|
1
|
|
1106
|
use experimental qw/ signatures postderef /; |
|
1
|
|
|
|
|
2811
|
|
|
1
|
|
|
|
|
5
|
|
21
|
|
|
|
|
|
|
|
22
|
1
|
|
|
1
|
0
|
2
|
sub project_config ($self, $project ) { |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
2
|
|
23
|
1
|
50
|
|
|
|
14
|
my $config = $self->tw->config->{project} or return {}; |
24
|
|
|
|
|
|
|
|
25
|
1
|
|
|
|
|
91
|
my @levels = split /\./, $project; |
26
|
|
|
|
|
|
|
|
27
|
1
|
|
|
|
|
3
|
my $aggregated = ''; |
28
|
|
|
|
|
|
|
|
29
|
1
|
|
|
|
|
4
|
while( my $l = shift @levels ) { |
30
|
2
|
50
|
|
|
|
6
|
$config = $config->{$l} or last; |
31
|
2
|
|
|
|
|
8
|
$aggregated = $config->{defaults} .' '. $aggregated; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
1
|
|
|
|
|
5
|
return $aggregated; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
1
|
|
|
1
|
0
|
2644
|
sub on_add ( $self, $task ) { |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
2
|
|
38
|
|
|
|
|
|
|
# no project? nothing to do |
39
|
1
|
50
|
|
|
|
5
|
my $project = $task->{project} or return; |
40
|
|
|
|
|
|
|
|
41
|
1
|
50
|
|
|
|
9
|
my $defaults = $self->project_config( $project ) |
42
|
|
|
|
|
|
|
or return; |
43
|
|
|
|
|
|
|
|
44
|
1
|
|
66
|
|
|
19
|
$task->{$1} ||= $2 while $defaults =~ /\b(\S+):(\S+)\b/g; |
45
|
|
|
|
|
|
|
|
46
|
1
|
|
|
|
|
13
|
push $task->{tags}->@*, $1 while $defaults =~ /\+(\S+)/g; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
__END__ |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=pod |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=encoding UTF-8 |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 NAME |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Taskwarrior::Kusarigama::Plugin::ProjectDefaults - assign project-level defaults when creating tasks |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 VERSION |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
version 0.12.0 |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 SYNOPSIS |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
$ task config project.dailies.defaults 'recur:1d +daily due:tomorrow' |
68
|
|
|
|
|
|
|
$ task add water the plants project:dailies |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 DESCRIPTION |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
If a task is created with a project, the plugin looks if there is a |
73
|
|
|
|
|
|
|
C<defaults> assigned to the project, and if so, defaults the values. |
74
|
|
|
|
|
|
|
In the case of array values (i.e., tags), the defaults are appended |
75
|
|
|
|
|
|
|
to the already provided values (if any). |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
The defaults of hierarchical projects are cumulative. So you can do things like |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
$ task config project.work.defaults 'priority:M' |
80
|
|
|
|
|
|
|
$ task config project.work.projectx.defaults 'due:eom' |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
$ task add ticket ABC-123 project:work.projectx |
83
|
|
|
|
|
|
|
# will get due:eom and priority:M |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 AUTHOR |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Yanick Champoux <yanick@cpan.org> |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
This software is copyright (c) 2019, 2018, 2017 by Yanick Champoux. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
94
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=cut |