chiark / gitweb /
use angle brackets in option msg
[d.git] / service
diff --git a/service b/service
index 44f4442e8095a88a4ec98dcc6647355006977ce7..f11894e6aee02ecc97cc1147149d4e3e036ebd97 100755 (executable)
--- a/service
+++ b/service
@@ -2,10 +2,10 @@
 our $usage1 = <<'END';
 usage: ../fyvzl [OPTIONS DATABASE-FILE ACTION ARG
 options
-  -lLENGTH   (for create)
-  -mMAXPERUSER
-  -dDOM
-  -qQUALDOM
+  -l<minrandlength>   (for create/choose, number of letters)
+  -m<maxperuser>
+  -d<dom>
+  -q<qualdom>
   -C     (show comments in output)
   -h     (display help)
 END
@@ -41,6 +41,7 @@ our $dom;
 our $user;
 our $priv;
 our $showcomment;
+our $genmethod = 'alphanum';
 
 sub nextarg () {
     die "too few arguments\n" unless @ARGV;
@@ -160,16 +161,21 @@ sub local_part_inuse ($) {
     return !!$row;
 }
 
+sub gen_local_part_alphanum {
+    my $s = chr(ord('a')+goodrand(26));
+    while (length $s < $randlength) {
+       my $v = goodrand(36);
+       $s .= chr($v < 26
+                 ? ord('a')+($v)
+                 : ord('0')+($v-26));
+    }
+    return $s;
+}
+
 sub generate_local_part () {
     my $s;
     for (;;) {
-       $s = chr(ord('a')+goodrand(26));
-       while (length $s < $randlength) {
-           my $v = goodrand(36);
-           $s .= chr($v < 26
-                     ? ord('a')+($v)
-                     : ord('0')+($v-26));
-       }
+       { no strict qw(refs); $s = &{"gen_local_part_$genmethod"}; }
 #      print STDERR "$s\n";
        last if !local_part_inuse($s);
     }
@@ -210,7 +216,7 @@ sub action_choose {
        print "\n" or die $!;
        $s{$s} = 1;
     }
-    print "# enter addresses or local parts to create,".
+    print "# ready - enter addrs or local-parts to create,".
        " then \`.' on a line by itself\n"
        or die $!;
 
@@ -231,7 +237,7 @@ sub action_choose {
            prow($newrow);
        } else {
            $dbh->rollback();
-           print "!error: $@" or die $!;
+           print "! error: $@" or die $!;
        }
     }
 }