chiark / gitweb /
clarify usage message
[d.git] / fyvzl
diff --git a/fyvzl b/fyvzl
index 8fe4e73c429548124cafbe0a0149ff41817655e7..c5dbfe498874e928155fcd3ab1fe3e2ad9419374 100755 (executable)
--- a/fyvzl
+++ b/fyvzl
@@ -11,12 +11,12 @@ options
 END
 our $usage2 = <<'END';
 actions
-  create [REDIRECT] [#COMMENT]
+  create [REDIRECT] [#COMMENT]    (default for REDIRECT is your username)
   update LOCAL-PART [REDIRECT] [#COMMENT]
   show LOCAL-PART
   list
   list-actions
-empty value for REDIRECT means reject
+empty string for REDIRECT means reject
 END
 our $usage3 = <<'END';
 privileged actions
@@ -117,13 +117,18 @@ sub insertrow ($) {
 }
 
 sub rhsargs ($) {
-    my ($row) = @_;
+    my ($defrow) = @_;
+    my $row = { };
     while (@ARGV) {
        $_ = shift @ARGV;
        my $f = (s/^\#// ? 'comment' : 'redirect');
        die "$f supplied twice\n" if exists $row->{$f};
        $row->{$f} = $_;
     }
+    foreach my $f (keys %$defrow) {
+       next if defined $row->{$f};
+       $row->{$f} = $defrow->{$f};
+    }
     qualify $row->{'redirect'};
     return $row;
 }
@@ -199,14 +204,19 @@ sub action_show {
     prow($row);
 }
 
+sub listq ($) {
+    my ($q) = @_;
+    while (my $row = $q->fetchrow_hashref()) {
+       prow($row);
+    }
+}
+
 sub action_list {
     nomoreargs;
     my $q = $dbh->prepare("SELECT * FROM addrs WHERE user=?".
                          " ORDER BY localpart");
     $q->execute($user);
-    while (my $row = $q->fetchrow_hashref()) {
-       prow($row);
-    }
+    listq($q);
 }
 
 sub action_list_user {
@@ -216,6 +226,15 @@ sub action_list_user {
     action_list;
 }
 
+sub action_list_all {
+    die unless $priv;
+    nomoreargs;
+    my $q = $dbh->prepare("SELECT * FROM addrs".
+                         " ORDER BY user, localpart");
+    $q->execute();
+    listq($q)
+}
+
 sub action_insert_exact {
     die unless $priv;
     my $row = { };