#!/usr/bin/perl

$todofile="debian/TODO";

=head1 NAME

todo - adds or lists todo entries to a TODO file


=head1 SYNOPSIS

todo [text] ...


=head1 DESCRIPTION

This is a tool to manage todolists. It is supposed to be invoked from anywhere
within a debian package source tree, and if it is it will find the debian
directory and apend all it's arguments to a TODO file there. The TODO file
will be created if no excists. If invoked with no arguments a nicely formated
list of the items in the TODO file will be presented.

=cut

# Look for the debian directory
until (-e "debian/changelog")
{
	chdir "..";
	if (`pwd` eq "/\n")
	{
		printf "Cannot find a todo file to edit anywhere\n";
		exit(1);
	}
}

if ($#ARGV == -1) {
    open (TODO, "<$todofile");
    $i=1;
    while (<TODO>){
	if ($i < 10){$a=" $i";} else {$a=$i;}
	print "$a: $_";
	$i++;
    }
    close (TODO);
} else {
    $Ide=join(" ", @ARGV);
    open (TODO, ">>$todofile");
    print TODO "$Ide\n";
    close (TODO);
}

=head1 SEE ALSO

deb-make(1)


=head1 AUTHOR

Hakan Ardo <hakan@debian.org>

=cut
