Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
101 additions
and
18 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/usr/bin/env perl | ||
use strict; use warnings; | ||
use App::Rad qw/+App::doing/; | ||
App::Rad->run; | ||
|
||
sub add | ||
:Help(add a new entry to your 'Currently Doing' file){ | ||
my $c = shift; | ||
my $message; | ||
if($c->options->{m}){ $message = shift $c->argv; } | ||
return $c->add($message); | ||
} | ||
|
||
sub default { | ||
open my $fh, '<', '.doing.log' or return; | ||
my $res = <$fh>; | ||
while(<$fh>){ | ||
last unless /^\t/; | ||
$res.=$_; | ||
} | ||
return $res; | ||
} | ||
|
||
# ABSTRACT: Keep track of what you were doing in a folder! | ||
# PODNAME: doing | ||
|
||
=head1 NAME | ||
doing - keep track of what you were doing in a folder! | ||
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,58 @@ | ||
use strict; | ||
use warnings; | ||
package App::doing; | ||
use File::Copy; | ||
use DateTime; | ||
|
||
# ABSTRACT: Doesn't matter what it does, it is awesome anyway! (TODO: change this -- ups!) | ||
# ABSTRACT: Keep track of what you were doing in a folder! | ||
|
||
=head2 add | ||
Adds a new entry to the CURRENTLY_DOING file | ||
=cut | ||
|
||
sub add { | ||
my ($c,$message,$options) = @_; | ||
if (defined($message)){ | ||
_new_entry('.doing.log',$message); | ||
} | ||
else { | ||
_new_entry('.doing.log'); | ||
system('vim','.doing.log'); | ||
} | ||
return; | ||
} | ||
|
||
sub _new_entry { | ||
my ($file,$message) = @_; | ||
use DateTime; | ||
my $dt = DateTime->now; | ||
if(defined($message)){ | ||
$message =~ s/^(?!\t)/\t/gm; | ||
_push_file($file,"$dt\n$message\n"); | ||
} | ||
else { | ||
_push_file($file,"$dt\n"); | ||
} | ||
} | ||
|
||
sub _push_file { | ||
my ($file,$message,$options) = @_; | ||
copy($file,"$file.old") if -f $file; | ||
open my $out, '>', $file; | ||
print $out "$message\n"; | ||
|
||
if (-f "$file.old"){ | ||
open my $in, '<', "$file.old"; | ||
while(<$in>){ | ||
print $out $_; | ||
} | ||
close $in; | ||
unlink ("$file.old"); | ||
} | ||
|
||
close $out; | ||
} | ||
|
||
1; |