summaryrefslogtreecommitdiffstats
path: root/lib/Reply/Plugin/Autocomplete/Commands.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Reply/Plugin/Autocomplete/Commands.pm')
-rw-r--r--lib/Reply/Plugin/Autocomplete/Commands.pm19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/Reply/Plugin/Autocomplete/Commands.pm b/lib/Reply/Plugin/Autocomplete/Commands.pm
new file mode 100644
index 0000000..ec86208
--- /dev/null
+++ b/lib/Reply/Plugin/Autocomplete/Commands.pm
@@ -0,0 +1,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;