aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Kangas <skangas@skangas.se>2011-03-21 22:31:02 +0100
committerStefan Kangas <skangas@skangas.se>2011-03-21 22:31:02 +0100
commitc7701570975feab6dd268802c6f552381d691529 (patch)
tree7aa9312668e2e6c98586ab1d07d09b1543b4439d
parent7a522692d79d68d276fad9edf233530f68dadb7e (diff)
Updates
-rwxr-xr-xfripost-newalias4
-rwxr-xr-xfripost-newdomain10
-rwxr-xr-xlib/Fripost/Prompt.pm4
3 files changed, 8 insertions, 10 deletions
diff --git a/fripost-newalias b/fripost-newalias
index ecfa4bf..4592522 100755
--- a/fripost-newalias
+++ b/fripost-newalias
@@ -50,8 +50,8 @@ my $schema = Fripost::Schema->connect(
# Get information
my $goto = fix_username(shift @ARGV);
my @addr = @ARGV;
-$goto //= prompt_username("Alias goto address: ");
-@addr || push @addr, prompt "Alias address: ";
+$goto //= prompt_email("Alias goto address: ", 'is_user');
+@addr || push @addr, prompt "Alias from address: ";
# Show goto adress
say "goto adress: $goto";
diff --git a/fripost-newdomain b/fripost-newdomain
index cf781ed..99c2ce3 100755
--- a/fripost-newdomain
+++ b/fripost-newdomain
@@ -3,6 +3,7 @@
use 5.010_000;
use warnings;
use strict;
+use utf8;
=head1 NAME
@@ -10,8 +11,6 @@ fripost-newdomain - Add a new domain to the system
=cut
-our $VERSION = '0.01';
-
use FindBin qw($Bin);
use lib "$Bin/lib";
@@ -27,7 +26,7 @@ use YAML::Syck;
our $conf = LoadFile('default.yml');
GetOptions(
- 'dbi_dsn' => \$conf->{dbi_dsn},
+ 'dbi_dsn' => \$conf->{dbi_dsn},
'admuser=s' => \$conf->{admuser},
'admpass=s' => \$conf->{admpass},
'pretend' => \$conf->{pretend},
@@ -38,13 +37,12 @@ my $schema = Fripost::Schema->connect(
$conf->{dbi_dsn}, $conf->{admuser}, $conf->{admpass}, {} #\%dbi_params
);
-say "Adding a new domain.";
-
my %domain;
$domain{domain} = prompt "Domain name: ";
-$domain{description} = prompt_username("User to associate domain with: ");
+$domain{description} = prompt_email("Belongs to user: ", 'is_user');
## TODO: Make sure the user does exists
+## TODO: Warn if the user has a domain already
if ($conf->{pretend}) {
say "Nothing to do since we are only pretending...";
diff --git a/lib/Fripost/Prompt.pm b/lib/Fripost/Prompt.pm
index b41f806..bbc554d 100755
--- a/lib/Fripost/Prompt.pm
+++ b/lib/Fripost/Prompt.pm
@@ -32,9 +32,9 @@ sub confirm_or_abort {
sub fix_username {
my ($nam) = @_;
- if ($nam !~ /\@/) {
+ if (defined $nam && $nam !~ /\@/) {
$nam .= '@fripost.org';
- say "Using username: $nam";
+ say "Using $nam";
}
return $nam;
}