diff options
Diffstat (limited to 'mat')
-rwxr-xr-x | mat | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -296,6 +296,7 @@ sub cmd_randweek { sub cmd_help() { print "help\n"; print "addrecipe\n"; + print "searchrecipes <search_string>\n"; print "editrecipe <recipe_id>\n"; print "showrecipe <recipe_id>\n"; print "movemeal <source_date> <destination_date>\n"; @@ -451,6 +452,21 @@ sub cmd_showrecipe { return 1; } +sub cmd_searchrecipes { + # Argument is search regexp + + my ( $regex ) = @_; + + while (my ($i, $recipe) = each @recipes) { + next if not defined($recipe); + if(grep(/$regex/i, $recipe->{'name'})) { + printf "%4d| %-50s\n", $i, $recipe->{'name'}; + } + } + + return 1; +} + sub cmd_shoppinglist { # Argument is number of days to shop for @@ -537,6 +553,8 @@ if ($ARGV[0]) { print "Command failed!\n" unless (cmd_help >= 0); } elsif ( $ARGV[0] eq "addrecipe") { print "Command failed!\n" unless (cmd_addrecipe() >= 0); + } elsif ( $ARGV[0] eq "searchrecipes") { + print "Command failed!\n" unless (cmd_searchrecipes($ARGV[1]) >= 0); } elsif ( $ARGV[0] eq "editrecipe") { print "Command failed!\n" unless (cmd_editrecipe($ARGV[1]) >= 0); } elsif ( $ARGV[0] eq "showrecipe") { |