+
+ # switch args (e.g. lei q -f mbox<TAB>)
+ if (($argv[-1] // $cur // '') =~ /\A--?([\w\-]+)\z/) {
+ my $opt = quotemeta $1;
+ puts $self, map {
+ my $v = $OPTDESC{$_};
+ $v = $v->[0] if ref($v);
+ my @v = split(/\|/, $v);
+ # get rid of ALL CAPS placeholder (e.g "OUT")
+ # (TODO: completion for external paths)
+ shift(@v) if uc($v[0]) eq $v[0];
+ @v;
+ } grep(/\A(?:$cmd\t|)(?:[\w-]+\|)*$opt\b/, keys %OPTDESC);
+ }
+ $cmd =~ tr/-/_/;
+ if (my $sub = $self->can("_complete_$cmd")) {
+ puts $self, $sub->($self, @argv, $cur);
+ }