summaryrefslogtreecommitdiffstats
path: root/lib/Reply/Plugin/Autocomplete/Commands.pm
blob: ec86208fcc3155b4a56543c711db5a8a907778cc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
package Reply::Plugin::Autocomplete::Commands;
use strict;
use warnings;

use base 'Reply::Plugin';

sub tab_handler {
    my $self = shift;
    my ($line) = @_;

    my ($prefix) = $line =~ /^#(.*)/;
    return unless defined $prefix;

    my @commands = $self->publish('commands');

    return map { "#$_" } sort grep { index($_, $prefix) == 0 } @commands;
}

1;