summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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);
}