| 1 | package Shell::Amazon::S3::Plugin::Completion; | ||
| 2 | use strict; | ||
| 3 | use Shell::Amazon::S3::Plugin; | ||
| 4 | use Scalar::Util 'weaken'; | ||
| 5 | use namespace::clean -except => ['meta']; | ||
| 6 | |||
| 7 | sub BEFORE_PLUGIN { | ||
| 8 | my ($self) = @_; | ||
| 9 | |||
| 10 | my $weakself = $self; | ||
| 11 | weaken($weakself); | ||
| 12 | |||
| 13 | $self->term->Attribs->{completion_function} = sub { | ||
| 14 | $weakself->_completion(@_); | ||
| 15 | }; | ||
| 16 | } | ||
| 17 | |||
| 18 | sub _completion { | ||
| 19 | my ( $self, $text, $line, $start, $end ) = @_; | ||
| 20 | |||
| 21 | my @command_list = qw( | ||
| 22 | bucket count createbucket delete deleteall deletebucket | ||
| 23 | exit get getfile getacl gettorrent head host help list listbuckets listatom | ||
| 24 | listrss pass put putfile putfilewacl quit setacl user | ||
| 25 | ); | ||
| 26 | |||
| 27 | my @matched = grep { $_ =~ /^$text/ } @command_list; | ||
| 28 | return @matched; | ||
| 29 | } | ||
| 30 | |||
| 31 | sub complete { | ||
| 32 | return (); | ||
| 33 | } | ||
| 34 | |||
| 35 | 1; | ||
| 36 |