summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcos <cos>2011-08-08 20:44:06 +0200
committercos <cos>2011-08-08 20:44:06 +0200
commit5783e29a949e233957db576b5bd0431a79d94f16 (patch)
tree9521df1a5ffbaa5e0aca97cd3e1d84b1bb5cefb6
parent11c1de92f5d6b5757cc96fba0a17c63dd9617c70 (diff)
downloadmat-5783e29a949e233957db576b5bd0431a79d94f16.zip
Added addrecipe command.
-rwxr-xr-xmat25
1 files changed, 25 insertions, 0 deletions
diff --git a/mat b/mat
index 4880292..1da3f6c 100755
--- a/mat
+++ b/mat
@@ -194,6 +194,28 @@ sub cmd_help() {
print "Help yet to be implemented\n";
}
+sub cmd_addrecipe {
+ # FIXME Make it possible to provide name and uri as command line arguments
+ # instead of solely interactive mode.
+
+ my ( $recipe_name, $uri, $answer, $sql );
+ print "Recipe name: ";
+ $recipe_name = <STDIN>;
+ chomp $recipe_name;
+ print "E.g. http://stupid.domain.name/node/755, urn:isbn:9789127118348#102\n";
+ print "Recipe uri: ";
+ $uri = <STDIN>;
+ chomp $uri;
+
+ $sql = "INSERT INTO recipes (name, uri) VALUES ('$recipe_name', '$uri');";
+ print "$sql\n\n";
+ print "Add to database? (y/n): ";
+ $answer = <STDIN>;
+ if ($answer eq "y\n") {
+ $db->do($sql);
+ }
+}
+
# MAIN PROGRAM ################################################################
read_recipe_db;
@@ -202,6 +224,9 @@ if ($ARGV[0]) {
if ( $ARGV[0] eq "help") {
print "Command failed!\n" unless (cmd_help >= 0);
}
+ if ( $ARGV[0] eq "addrecipe") {
+ print "Command failed!\n" unless (cmd_addrecipe() >= 0);
+ }
if ( $ARGV[0] eq "setmeal") {
print "Command failed!\n" unless (cmd_setmeal($ARGV[1], $ARGV[2]) >= 0);
}