3 our $pgm = $0; $pgm =~ s#.*/##;
6 $pgm [<opts>] update <number>|<localpart>@[domain] [<reason>] [<comment>]
7 $pgm [<opts>] assign <number>|<localpart>@[domain] <comment>
8 $pgm [<opts>] show <count> } will generate more aliases
9 $pgm [<opts>] range [<from>-[<to>]] } if necessary
11 -G<generator> generator/lister program
12 -N do not generate more aliases
13 -l.., -d.., -F.., -m.. passed to generator
15 Always use $pgm to edit the comment of a pregen alias;
16 otherwise we may lose track of the next number alias to pregenerate
18 <comment> must always start with #, and you will need to quote the
19 whole comment to protect it from your shell
26 open P, "-!", $generator, qw(list) or die $!;
31 } elsif (m/^\# reject (\S+) (\#.*)$/) {
32 ($alias,$comment) = ($1,$2);
34 next; # future extension
35 } elsif (m/^([^#: ])\: [^#]* (\#.*)$/) {
36 ($alias,$comment) = ($1,$2);
38 die "generator output $_ ?";
40 my $localpart = $alias;
41 $localpart =~ s/\@.*//;
42 my $row = { Alias => $alias, LocalPart => $localpart };
43 if ($comment =~ m/^### PREGEN ([1-9]\d{0,8})$/) {
46 $by_localpart{$row->{LocalPart}} = $row;
47 $by_number[$row->{Number}] = $row if defined $row->{Number};
49 $?=0; $!=0; close P or die "$generator $! $?";
54 @ARGV or badusage "missing specification for alias to change";
55 my $spec = shift @ARGV;
57 if ($spec =~ m/^(\d{1,9})$/) {
58 $target = $by_number[$spec];
59 die "no alias number $target\n" unless $target;
60 } elsif ($spec =~ m/^(.*)\@[^\@]*/) {
61 $target = $by_localpart{$1};
62 die "no alias with local part \`$1'\n" unless $target;
63 die "incorrect or unchecked domain: \`$target->{Alias}' != \`$spec'\n"
64 unless $spec eq $target->{Alias} ||
65 $spec eq $target->{LocalPart}.'@';
67 badusage "bad specification for alias to change";
72 my $target = parse_target;
73 @ARGV or badusage "missing update info\n";
74 if (defined $target->{Number} && $target->{Number} == $#by_number) {
75 generate $target->{Number}+1;
77 exec $generator, qw(update), $target->{Alias}, @ARGV;
84 badusage "invalid arguments to assign - forgot to quote it properly?";
89 (@ARGV==1 && $ARGV[0] =~ or badusage "missing assignment info (new comment)";
94 last unless $ARGV[0] =~ m/^-/;
95 my $arg = shift @ARGV;
96 last if $arg =~ m/^--?$/;
97 if ($arg =~ m/^-[ldFm]/) {
99 } elsif ($arg =~ m/^-G/) {
102 badusage "unknown option \`$arg'";
107 $child =~ s/-pregen/; fixme fixme this should be defaulting generator
109 @ARGV or badusage "missing action\n";
110 my $action = shift @ARGV;
112 { no strict qw(refs); &{"action_$action"}; }