Make sure -d and -D work as expected
[infodrom.org/service.infodrom.org] / src / InfoCon / stempel / stempel
index c73fdec..b29fdc3 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/perl
 
 #  InfoCon Time Tracker
-#  Copyright (c) 2007,8,13,14,15  Martin Schulze <joey@infodrom.org>
+#  Copyright (c) 2007,8,13,14,15,20  Joey Schulze <joey@infodrom.org>
 #
 #  This program is free software; you can redistribute it and/or modify
 #  it under the terms of the GNU General Public License as published by
@@ -172,7 +172,7 @@ sub close_task
     my $query = q{SELECT oid,start FROM stempel WHERE stop IS NULL};
     my $sth = $dbh->prepare ($query);
     if ($sth && $sth->execute > 0) {
-       while ((my $row = $sth->fetchrow_hashref)) {
+       if ((my $row = $sth->fetchrow_hashref)) {
            my @arr = split(/ /, $row->{start});
            my @d = split(/-/, $arr[0]);
 
@@ -182,7 +182,7 @@ sub close_task
                    $today = 0;
                } else {
                    printf "Task not started today, aborting, use -D if this is intentional.\n";
-                   next;
+                   exit;
                }
            }
 
@@ -389,9 +389,10 @@ my %options = ('list:s' => \$opt_list,
               'delete' => \&delete_task,
               'reopen' => \&reopen_task,
               'task|t' => \&alter_task,
-              'terminate|end|d' => \&close_task,
+              'terminate|end|d' => sub {close_task(0);},
               'D' => sub {close_task(1);},
               );
+Getopt::Long::Configure('no_ignore_case');
 GetOptions %options;
 
 if ($opt_close) {