Merge pull request #827 from cgagnaire/redis
add password option on rediscli custom mode
This commit is contained in:
commit
0a978bf718
|
@ -44,6 +44,7 @@ sub new {
|
|||
{
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
"port:s" => { name => 'port' },
|
||||
"password:s" => { name => 'password' },
|
||||
});
|
||||
}
|
||||
$options{options}->add_help(package => __PACKAGE__, sections => 'REDIS CLI OPTIONS', once => 1);
|
||||
|
@ -81,6 +82,7 @@ sub check_options {
|
|||
|
||||
$self->{hostname} = $self->{option_results}->{hostname};
|
||||
$self->{port} = $self->{option_results}->{port};
|
||||
$self->{password} = $self->{option_results}->{password};
|
||||
|
||||
if (!defined($self->{hostname})) {
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify hostname argument.");
|
||||
|
@ -104,6 +106,9 @@ sub get_info {
|
|||
my ($self, %options) = @_;
|
||||
|
||||
$self->{redis} = Redis->new(server => $self->{hostname} . ":" . $self->{port});
|
||||
if (defined($self->{password})) {
|
||||
$self->{redis}->auth($self->{password});
|
||||
}
|
||||
|
||||
my $response = $self->{redis}->info;
|
||||
my $items;
|
||||
|
@ -111,6 +116,8 @@ sub get_info {
|
|||
$items->{$attributes} = $response->{$attributes};
|
||||
}
|
||||
|
||||
$self->{redis}->quit();
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
|
@ -138,6 +145,10 @@ Redis hostname.
|
|||
|
||||
Redis port.
|
||||
|
||||
=item B<--password>
|
||||
|
||||
Redis password
|
||||
|
||||
=back
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
|
Loading…
Reference in New Issue