Created
August 2, 2017 14:26
-
-
Save jacoby/99b1fe2b172d4b4eab84d459256776da to your computer and use it in GitHub Desktop.
Stores a record of my daily activities
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict ; | |
use warnings ; | |
use feature qw{ postderef say signatures state } ; | |
no warnings qw{ experimental::postderef experimental::signatures } ; | |
use Carp ; | |
use Getopt::Long ; | |
use IO::Interactive qw{ interactive } ; | |
use Pod::Usage ; | |
use lib $ENV{ HOME } . '/lib' ; | |
use Status ; | |
my $config = config() ; | |
if ( $config->{ status } =~ /\w/ ) { | |
if ( set_status( $config->{ status } ) ) { | |
say { interactive } qq{\t$config->{status}}; | |
} | |
else { | |
croak q{Could not write record: $!}; | |
} | |
} | |
exit ; | |
sub config () { | |
my $config ; | |
GetOptions( | |
'man' => \$config->{ man }, | |
'help' => \$config->{ help }, | |
'status=s' => \$config->{ status }, | |
) ; | |
pod2usage( { -verbose => 2, -exitval => 1 } ) if $config->{ man } ; | |
pod2usage( 1 ) && exit if $config->{ help } || !$config->{ status } ; | |
return $config ; | |
} | |
=head1 NAME | |
record.pl - what I did today | |
=head1 SYNOPSIS | |
record.pl -s status | |
record.pl -h | |
record.pl -m | |
=head1 DESCRIPTION | |
Stores records of daily activity in MongoDB to be pulled out later | |
as a daily report to Phillip. | |
=head1 OPTIONS | |
=over 4 | |
=item B<-s>, B<--status> | |
The text of the report. Required. | |
=item B<-h>, B<--help> | |
Display this text | |
=item B<-m>, B<--man> | |
Display the man pages, written in POD form | |
=back | |
=head1 LICENSE | |
This is released under the Artistic | |
License. See L<perlartistic>. | |
=head1 AUTHOR | |
Dave Jacoby L<jacoby.david@gmail.com> | |
=cut |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment