Created
March 10, 2012 12:15
-
-
Save squeeks/2011262 to your computer and use it in GitHub Desktop.
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 | |
=head1 NAME | |
todo - The revolutionary way to keep track of your source code today! | |
=head1 SYNOPSIS | |
Do you find yourself using clunky, convoluted bug tracking and task management | |
software on a day to day basis? Does the thought of traditional bug trackers | |
make you want to off yourself? Well hacker, have no fear C<todo> could change | |
your life today for all those small, drunken late night hacks. It doesn't | |
matter if you're at a conference, in your bedroom or stuck on a bus en route to | |
Singapore - C<todo> can revolutionise the wa yyou keep track of the questionable | |
things you wrote in an attempt to prove Ballmer's peak exists. | |
It's really simple: As you hack, pepper your code with comments like this: | |
#TODO Need to find new way to reinvent wheel | |
or... | |
// FIXME Passwords probably shouldn't be stored as plain text | |
And finally, for the brave: | |
/* HACKHACKHACK Compiler warnings? What compiler warnings? | |
It's that easy folks. For as long as you make your comments sensible to at least | |
yourself, only your code should make you yell "WTF!" the morning after. C<todo> is | |
completely Language Agnostic* and anything where the ratio of product pitch | |
versus actual code is greater than one must be reliable and trustworthy! | |
* Not all languages tested to confirm compatibility. | |
=head1 USAGE | |
todo <thingname> | |
=head1 AUTHOR | |
Squeeks - squeek@cpan.org | |
=head1 LICENSE | |
Exactly the same as Perl folks, which makes it available for the low, low price | |
of €0! Download now! | |
=cut | |
use strict; | |
use warnings; | |
die "Usage: todo <files or folders>" unless $#ARGV >= 0; | |
foreach my $thing(@ARGV) { | |
if(-d $thing) { | |
my @files = glob $thing."*.*"; | |
for my $file(@files){ | |
my $todo; | |
$todo = parse_file($file) if -T $file; | |
print $file."\n\n", $todo if $todo; | |
} | |
} elsif(-T $thing) { | |
my $todo = parse_file($thing); | |
print $todo if $todo; | |
} | |
} | |
sub parse_file { | |
my $filename = shift; | |
open my $fh, $filename or die($!); | |
my $i = 1; | |
my $output = undef; | |
while(<$fh>) { | |
my $line = $_; | |
if($line =~/TODO|FIXME|HACKHACKHACK/) { | |
# TODO Yeah okay, let's do multiple lines later after we learn | |
# how to smart handle comment markers (/* \n * \n */ will screw me) | |
my($type,$thing) = $line =~/(TODO|FIXME|HACKHACKHACK)\s+(.*)/; | |
$output .= sprintf "%s - %s:%i\n%s\n\n", $type, $thing, $i, $thing; | |
} | |
$i++; | |
} | |
close $fh; | |
return $output; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment