JobLog/Command/note.pm untested

filter: Statementstmt 0.0% 0 / 31 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 10 Podpod 0.0% 0 / 6 totaltotal 0.0% 0 / 60 CC 5 SCAR 20.4
CC
5
Cov
0%
execute
20.0
validate
6.0
usage_desc
2.0
CRAP 7.7
1 package App::JobLog::Command::note;
2 $App::JobLog::Command::note::VERSION = '1.042';
3 # ABSTRACT: take a note
4  
5 use App::JobLog -command;
6 use Modern::Perl;
7 use autouse 'Getopt::Long::Descriptive' => qw(prog_name);
8 use Class::Autouse qw(App::JobLog::Log);
9  
10 sub execute {
11 my ( $self, $opt, $args ) = @_;
12 my $tags = $opt->tag;
13 my $log = App::JobLog::Log->new;
14 unless ( $tags || $opt->clear_tags ) {
15 my ($last) = $log->last_note;
16 $tags = $last->tags if $last;
17 }
18 $log->append_note(
19 $tags ? ( tags => $tags ) : (),
20 description => [ join ' ', @$args ],
21 );
22 }
23  
24 sub usage_desc { '%c ' . __PACKAGE__->name . ' <text of note>' }
25  
26 sub abstract { 'take a note' }
27  
28 sub full_description {
29 <<END;
30 Take a note. E.g.,
31  
32 @{[prog_name($0)]} @{[__PACKAGE__->name]} remember to get kids from school
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 '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 my ( $self, $opt, $args ) = @_;
60  
61 $self->usage_error('no note provided') unless @$args;
62 }
63  
64 1;
65  
66 __END__