diff options
author | Max Kanat-Alexander <mkanat@bugzilla.org> | 2010-06-21 19:25:37 -0700 |
---|---|---|
committer | Max Kanat-Alexander <mkanat@bugzilla.org> | 2010-06-21 19:25:37 -0700 |
commit | e3fd496e1ecc34f3db4c9415cf0ad387d56c6066 (patch) | |
tree | 0fdc0cf73dc06e7479b9d966692400f8d27a1964 | |
parent | 90a16d9ea359d7b9888577ec711430387f3b3de5 (diff) | |
download | bugs-e3fd496e1ecc34f3db4c9415cf0ad387d56c6066.tar bugs-e3fd496e1ecc34f3db4c9415cf0ad387d56c6066.tar.gz bugs-e3fd496e1ecc34f3db4c9415cf0ad387d56c6066.tar.bz2 bugs-e3fd496e1ecc34f3db4c9415cf0ad387d56c6066.tar.xz bugs-e3fd496e1ecc34f3db4c9415cf0ad387d56c6066.zip |
Bug 564082: Allow specifying defaults and overrides for incoming email
using command-line parameters to email_in.pl
r=timello, a=mkanat
-rwxr-xr-x | email_in.pl | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/email_in.pl b/email_in.pl index 4e44222d5..52ad27642 100755 --- a/email_in.pl +++ b/email_in.pl @@ -74,7 +74,7 @@ sub parse_mail { debug_print('Parsing Email'); $input_email = Email::MIME->new($mail_text); - my %fields; + my %fields = %{ $switch{'default'} || {} }; my $summary = $input_email->header('Subject'); if ($summary =~ /\[\S+ (\d+)\](.*)/i) { @@ -136,6 +136,11 @@ sub parse_mail { } $fields{'comment'} = $comment; + my %override = %{ $switch{'override'} || {} }; + foreach my $key (keys %override) { + $fields{$key} = $override{$key}; + } + debug_print("Parsed Fields:\n" . Dumper(\%fields), 2); return \%fields; @@ -383,7 +388,7 @@ sub die_handler { $SIG{__DIE__} = \&die_handler; -GetOptions(\%switch, 'help|h', 'verbose|v+'); +GetOptions(\%switch, 'help|h', 'verbose|v+', 'default=s%', 'override=s%'); $switch{'verbose'} ||= 0; # Print the help message if that switch was selected. @@ -434,13 +439,22 @@ email_in.pl - The Bugzilla Inbound Email Interface =head1 SYNOPSIS - ./email_in.pl [-vvv] < email.txt +./email_in.pl [-vvv] [--default name=value] [--override name=value] < email.txt + +Reads an email on STDIN (the standard input). + +Options: + + --verbose (-v) - Make the script print more to STDERR. + Specify multiple times to print even more. - Reads an email on STDIN (the standard input). + --default name=value - Specify defaults for field values, like + product=TestProduct. Can be specified multiple + times to specify defaults for multiple fields. - Options: - --verbose (-v) - Make the script print more to STDERR. - Specify multiple times to print even more. + --override name=value - Override field values specified in the email, + like product=TestProduct. Can be specified + multiple times to override multiple fields. =head1 DESCRIPTION |