summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcos <cos>2011-08-29 11:24:39 +0200
committercos <cos>2012-12-17 21:12:06 +0100
commitb3958aa1cbae5a373e202ddd2db3031a30020eb3 (patch)
tree2c4feddfe683f3452d7e2d234d73b7cab5dcd647
parenta00925512c1ca924292d0a4b6e161d46a7d6d54c (diff)
downloadmat-b3958aa1cbae5a373e202ddd2db3031a30020eb3.zip
Add movemeal command.
-rwxr-xr-xmat19
1 files changed, 19 insertions, 0 deletions
diff --git a/mat b/mat
index 0aef88a..bed1f66 100755
--- a/mat
+++ b/mat
@@ -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);
}