diff options
Diffstat (limited to 'fripost-newalias')
-rwxr-xr-x | fripost-newalias | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/fripost-newalias b/fripost-newalias index 2668943..162f787 100755 --- a/fripost-newalias +++ b/fripost-newalias @@ -8,14 +8,18 @@ use strict; fripost-newalias - Add a new alias to the system -=cut +=head1 SYNOPSIS + +fripost-newalias +fripost-newalias GOTO FROM... -our $VERSION = '0.01'; +=cut use FindBin qw($Bin); use lib "$Bin/lib"; use Data::Dumper; +use Email::Valid; use Fripost::Password; use Fripost::Prompt; use Fripost::Schema; @@ -38,11 +42,10 @@ my $schema = Fripost::Schema->connect( $conf->{dbi_dsn}, $conf->{admuser}, $conf->{admpass}, {} #\%dbi_params ); -my $goto = shift @ARGV; +# Get information +my $goto = fix_username(shift @ARGV); my @addr = @ARGV; - $goto //= prompt_username("Alias goto address: "); - @addr || push @addr, prompt "Alias address: "; if ($conf->{pretend}) { @@ -50,6 +53,26 @@ 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({ |