diff options
author | Stefan Kangas <skangas@skangas.se> | 2011-03-11 21:25:38 +0100 |
---|---|---|
committer | Stefan Kangas <skangas@skangas.se> | 2011-03-11 21:25:38 +0100 |
commit | df00a5d274e5c06162255ac68b213afe66ec56b0 (patch) | |
tree | 5a2a61dd2c70e70ba6416c8e1eb9a3502500fa0b | |
parent | c965c8bf6ec78123110ad0ad3ca623634f950814 (diff) |
Make newalias nice
-rwxr-xr-x | fripost-newalias | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/fripost-newalias b/fripost-newalias index 53dd3e4..162f787 100755 --- a/fripost-newalias +++ b/fripost-newalias @@ -15,8 +15,6 @@ fripost-newalias GOTO FROM... =cut -our $VERSION = '0.01'; - use FindBin qw($Bin); use lib "$Bin/lib"; @@ -45,7 +43,7 @@ my $schema = Fripost::Schema->connect( ); # Get information -my $goto = shift @ARGV; +my $goto = fix_username(shift @ARGV); my @addr = @ARGV; $goto //= prompt_username("Alias goto address: "); @addr || push @addr, prompt "Alias address: "; @@ -55,16 +53,32 @@ if ($conf->{pretend}) { exit 0; } +# Show goto adress +say "goto adress: $goto"; + +# Show from adresses +@addr = grep { + if (Email::Valid->address($_)) { + 1; + } + else { + say "WARN: skipping invalid address $_"; + undef; + } +} @addr; +if (@addr == 0) { + say "No valid destination adresses. Aborting..."; + exit 1; +} +say "dest adress: " . (join " ", @addr); +ask_if_ok_or_abort(); + ## Insert alias into database for my $addr (@addr) { my $rs = $schema->resultset('Alias')->search({ address => $addr, }); if (!$rs->count) { - unless (Email::Valid->address($addr)) { - say "WARN: skipping invalid address $addr"; - next; - } my $db_alias = $schema->resultset('Alias')->new({ address => $addr, goto => $goto, |