File Coverage

blib/lib/App/JobLog/Command/note.pm
Criterion Covered Total %
statement 23 27 85.1
branch 4 8 50.0
condition 1 3 33.3
subroutine 8 10 80.0
pod 3 6 50.0
total 39 54 72.2


line stmt bran cond sub pod time code
1             package App::JobLog::Command::note;
2             $App::JobLog::Command::note::VERSION = '1.041';
3             # ABSTRACT: take a note
4              
5 2     2   1567 use App::JobLog -command;
  2         3  
  2         15  
6 2     2   831 use Modern::Perl;
  2         5  
  2         11  
7 2     2   262 use autouse 'Getopt::Long::Descriptive' => qw(prog_name);
  2         3  
  2         12  
8 2     2   108 use Class::Autouse qw(App::JobLog::Log);
  2         4  
  2         12  
9              
10             sub execute {
11 1     1 1 6 my ( $self, $opt, $args ) = @_;
12 1         4 my $tags = $opt->tag;
13 1         10 my $log = App::JobLog::Log->new;
14 1 50 33     9 unless ( $tags || $opt->clear_tags ) {
15 1         11 my ($last) = $log->last_note;
16 1 50       5 $tags = $last->tags if $last;
17             }
18             $log->append_note(
19 1 50       13 $tags ? ( tags => $tags ) : (),
20             description => [ join ' ', @$args ],
21             );
22             }
23              
24 1     1 1 1745 sub usage_desc { '%c ' . __PACKAGE__->name . ' ' }
25              
26 0     0 1 0 sub abstract { 'take a note' }
27              
28             sub full_description {
29 0     0 0 0 <
30             Take a note. E.g.,
31              
32 0         0 @{[prog_name($0)]} @{[__PACKAGE__->name]} remember to get kids from school
  0         0  
33              
34             All arguments that are not parameter values are concatenated as the note. Notes
35             have a time but not a duration. See the summary command for how to extract notes
36             from the log.
37              
38             Notes may be tagged to assist in search or categorization.
39             END
40             }
41              
42             sub options {
43             return (
44             [
45 1     1 0 14 'tag|t=s@',
46             'tag the note; multiple tags are acceptable; e.g., -t foo -t bar -t quux',
47             ],
48             [
49             'clear-tags|T',
50             'inherit no tags from preceding note; '
51             . 'this is equivalent to -t ""; '
52             . 'this option has no effect if any tag is specified',
53             ],
54              
55             );
56             }
57              
58             sub validate {
59 1     1 0 2 my ( $self, $opt, $args ) = @_;
60              
61 1 50       6 $self->usage_error('no note provided') unless @$args;
62             }
63              
64             1;
65              
66             __END__