Changeset 1610e5b for perl/lib/BarnOwl


Ignore:
Timestamp:
Jul 29, 2009, 10:19:03 PM (12 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
ea7cfa8
Parents:
f907cf0
Message:
Implement completion for the 'show' command.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • perl/lib/BarnOwl/Complete/Client.pm

    r4fde21c r1610e5b  
    1818                    yellow);
    1919
     20my %show = (
     21    information => undef,
     22    colors      => undef,
     23    commands    => undef,
     24    command     => \&complete_command,
     25    filters     => undef,
     26    filter      => \&complete_filter_name,
     27    license     => undef,
     28    quickstart  => undef,
     29    startup     => undef,
     30    status      => undef,
     31    styles      => undef,
     32    subscriptions       => undef,
     33    subs        => undef,
     34    terminal    => undef,
     35    variables   => undef,
     36    variable    => \&complete_variable,
     37    version     => undef,
     38    view        => undef,
     39    zpunts      => undef,
     40   );
     41
    2042sub complete_command { return sort @BarnOwl::all_commands; }
    2143sub complete_color { return @all_colors; }
     44sub complete_filter_name { return @{BarnOwl::all_filters()}; }
     45sub complete_variable {}        # stub
    2246
    2347sub complete_filter_args {
     
    2549    my $arg = shift;
    2650    return if $arg;
    27     return @{BarnOwl::all_filters()};
     51    return complete_filter_name();
    2852}
    2953
     
    3660        \&complete_command
    3761       );
     62}
     63
     64sub complete_show {
     65    my $ctx = shift;
     66    if($ctx->word == 1) {
     67        return keys %show;
     68    } elsif ($ctx->word == 2) {
     69        my $cmd = $show{$ctx->words->[1]};
     70        if($cmd) {
     71            return $cmd->($ctx);
     72        }
     73    }
    3874}
    3975
     
    5288BarnOwl::Completion::register_completer(help    => \&complete_help);
    5389BarnOwl::Completion::register_completer(filter  => \&complete_filter);
     90BarnOwl::Completion::register_completer(show    => \&complete_show);
    5491
    55921;
Note: See TracChangeset for help on using the changeset viewer.