diff options
author | cos <cos> | 2011-08-29 11:24:39 +0200 |
---|---|---|
committer | cos <cos> | 2012-12-17 21:12:06 +0100 |
commit | b3958aa1cbae5a373e202ddd2db3031a30020eb3 (patch) | |
tree | 2c4feddfe683f3452d7e2d234d73b7cab5dcd647 | |
parent | a00925512c1ca924292d0a4b6e161d46a7d6d54c (diff) | |
download | mat-b3958aa1cbae5a373e202ddd2db3031a30020eb3.zip |
Add movemeal command.
-rwxr-xr-x | mat | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -123,6 +123,22 @@ sub cmd_setmeal { return 0; } +sub cmd_movemeal { + my ( $source, $destination ) = @_; + my $mealtype = "lunch"; + + return unless $source =~ "^[0-9]{4}-[0-9]{2}-[0-9]{2}\$"; + return unless $destination =~ "^[0-9]{4}-[0-9]{2}-[0-9]{2}\$"; + + my $sql = "SELECT FROM plan WHERE date='$source';"; +# FIXME Run and validate existance of source $db->do($sql); +# FIXME Handle if destination already exists + $sql = "UPDATE plan SET date='$destination' WHERE date='$source';"; + $db->do($sql); + + return 0; +} + sub cmd_setstate { my ( $date, $state ) = @_; my $mealtype = "lunch"; @@ -366,6 +382,9 @@ if ($ARGV[0]) { if ( $ARGV[0] eq "editrecipe") { print "Command failed!\n" unless (cmd_editrecipe($ARGV[1]) >= 0); } + if ( $ARGV[0] eq "movemeal") { + print "Command failed!\n" unless (cmd_movemeal($ARGV[1], $ARGV[2]) >= 0); + } if ( $ARGV[0] eq "setmeal") { print "Command failed!\n" unless (cmd_setmeal($ARGV[1], $ARGV[2]) >= 0); } |