Support changing the task title
[infodrom.org/service.infodrom.org] / src / InfoCon / stempel / stempel
index 9c66cdb..9f69d77 100755 (executable)
@@ -154,6 +154,7 @@ sub delete_task
 
 sub list_open
 {
+    my $exit = shift;
     my ($d_sec,$d_min,$d_hour,$d_mday,$d_mon,$d_year,$d_wday,$d_isdst) = localtime();
     my $query = q{SELECT customer,start,task FROM stempel WHERE time IS NULL ORDER BY start,customer};
 
@@ -176,7 +177,7 @@ sub list_open
            printf "%-15s  %s %s (%s)  %s\n", $row->{customer}, $day, $time, min2hour($int), $row->{task};
        }
     }
-    exit 0;
+    exit 0 if $exit;
 }
 
 sub list
@@ -217,7 +218,7 @@ sub list
 sub toggle_task
 {
     if (is_open) {
-       list_open;
+       list_open 1;
     } else {
        open_task;
     }
@@ -235,6 +236,24 @@ sub late_close_task
     $dbh->do($query);
 }
 
+sub alter_task
+{
+    return unless is_open;
+
+    list_open;
+
+    my $term = new Term::ReadLine '';
+
+    my $task = $term->readline ('Aufgabe: ');
+
+    if (length($task) > 0) {
+       my $query = q{UPDATE stempel SET task=? WHERE stop IS NULL};
+       my $sth = $dbh->prepare($query);
+       $sth->execute($task);
+    }
+    exit 0;
+}
+
 sub help
 {
     print <<"END";
@@ -245,6 +264,7 @@ stempel  Copyright (c) 2007,8  Martin Schulze <joey\@infodrom.org>
     --help         this text
     --end|-d       terminate task
     --delete       delete open task
+    --task         alter task content
 END
     exit;
 }
@@ -256,6 +276,7 @@ my %options = ('list:s' => \$opt_list,
               'help' => \&help,
               'close=i' => \$opt_close,
               'delete' => \&delete_task,
+              'task|t' => \&alter_task,
               'terminate|end|d' => \&close_task,
               );
 GetOptions %options;