chiark / gitweb /
alphanum tidyups
[d.git] / service
diff --git a/service b/service
index 2774f49073ac91c58dd3f2a921e8741554d980ab..bbcc43be545476f9b9c1df406d163181382c7fe8 100755 (executable)
--- a/service
+++ b/service
@@ -2,12 +2,13 @@
 our $usage1 = <<'END';
 usage: ../fyvzl [<options>] <database-file> <action> <arg>...
 options
-  -l<minrandlength>   (for create/choose, number of letters)
   -m<maxperuser>
   -d<dom>
   -q<qualdom>
   -C     (show comments in output)
   -h     (display help)
+options for alphanum generation
+  -l<minrandlength>   (for create/choose alphanum, minimum randlength)
 END
 our $usage2 = <<'END';
 actions
@@ -25,7 +26,13 @@ privileged actions
   insert-exact <addr> <user> <redirect> <comment>
   donate <addr> <user>
   enable-user|disable-user <user>
+default generation method is alphanum
 END
+our %usage_genopts = (
+'alphanum' => <<END,
+  -l<randlength>      (number of letters+digits)
+END
+);
 #/
 
 use strict;
@@ -33,10 +40,6 @@ use strict;
 use DBI;
 use POSIX;
 
-our $minrandlength = 6;
-our $randlength;
-our $maxrandlength = 50;
-
 our $maxperuser = 10000;
 our $qualdom;
 our $dbh;
@@ -46,6 +49,13 @@ our $priv;
 our $showcomment;
 our $genmethod = 'alphanum';
 
+# for alphanum
+#   options
+our $minrandlength = 6;
+our $maxrandlength = 100;
+#   genopts
+our $randlength;
+
 sub nextarg () {
     die "too few arguments\n" unless @ARGV;
     my $v = shift @ARGV;
@@ -198,7 +208,7 @@ sub prepare_create () {
 sub genopt_alphanum {
     local ($_) = @_;
     if (m/^-l(\d+)$/) {
-       $randlength = $1;
+       $randlength = 0+$1;
        die "length out of range $minrandlength..$maxrandlength\n"
            unless ($minrandlength<=$randlength &&
                    $randlength<=$maxrandlength);
@@ -383,6 +393,8 @@ sub action_disable_user {
 
 sub action_list_actions {
     print $usage2 or die $!;
+    print "genopts\n" or die $!;
+    print $usage_genopts{$genmethod} or die $!;
 }
 
 while (@ARGV) {
@@ -403,6 +415,10 @@ while (@ARGV) {
            $showcomment = 1;
        } elsif (s/^-h/-/) {
            print $usage1.$usage2.$usage3 or die $!;
+           foreach my $meth (qw(alphanum)) {
+               print "genopts for $meth generation method\n" or die $!;
+               print $usage_genopts{$meth} or die $!;
+           }
            exit 0;
        } else {
            die "unknown option \`$_'\n";