From 815d0fba7abfcad9924820a35e6c3531a4fa6f70 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Fri, 11 Mar 2011 20:46:03 +0100 Subject: Add SYNOPSIS to newalias --- fripost-newalias | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'fripost-newalias') diff --git a/fripost-newalias b/fripost-newalias index 2668943..fb50a0c 100755 --- a/fripost-newalias +++ b/fripost-newalias @@ -8,6 +8,11 @@ use strict; fripost-newalias - Add a new alias to the system +=head1 SYNOPSIS + +fripost-newalias +fripost-newalias GOTO FROM... + =cut our $VERSION = '0.01'; -- cgit v1.2.3 From c965c8bf6ec78123110ad0ad3ca623634f950814 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Fri, 11 Mar 2011 21:05:53 +0100 Subject: Use scalar context for File::Slurp --- fripost-newalias | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'fripost-newalias') diff --git a/fripost-newalias b/fripost-newalias index fb50a0c..53dd3e4 100755 --- a/fripost-newalias +++ b/fripost-newalias @@ -21,6 +21,7 @@ use FindBin qw($Bin); use lib "$Bin/lib"; use Data::Dumper; +use Email::Valid; use Fripost::Password; use Fripost::Prompt; use Fripost::Schema; @@ -43,11 +44,10 @@ my $schema = Fripost::Schema->connect( $conf->{dbi_dsn}, $conf->{admuser}, $conf->{admpass}, {} #\%dbi_params ); +# Get information my $goto = shift @ARGV; my @addr = @ARGV; - $goto //= prompt_username("Alias goto address: "); - @addr || push @addr, prompt "Alias address: "; if ($conf->{pretend}) { @@ -61,6 +61,10 @@ for my $addr (@addr) { 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, -- cgit v1.2.3 From df00a5d274e5c06162255ac68b213afe66ec56b0 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Fri, 11 Mar 2011 21:25:38 +0100 Subject: Make newalias nice --- fripost-newalias | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'fripost-newalias') 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, -- cgit v1.2.3