Add dump() command in cli

Closes: #1770
This commit is contained in:
Xavier 2019-05-30 09:39:36 +02:00
parent 6b5677b4ce
commit 00852d1a66
2 changed files with 9 additions and 2 deletions

View File

@ -22,7 +22,7 @@ for ( my $i = 0 ; $i < @ARGV ; $i++ ) {
$action ||= "help";
if ( $action =~ /^(?:[gs]et|(?:add|del)Key)$/ ) {
if ( $action =~ /^(?:[gs]et|(?:add|del)Key|dump)$/ ) {
eval { require Lemonldap::NG::Manager::Cli; };
die "Manager libraries not available, aborting ($@)" if ($@);
Lemonldap::NG::Manager::Cli->run(@ARGV);

View File

@ -194,6 +194,13 @@ sub lastCfg {
return $self->jsonResponse('/confs/latest')->{cfgNum};
}
sub dump {
my ($self) = @_;
my $conf = $self->jsonResponse( '/confs/latest', 'full=1' );
my $json = JSON->new->indent->canonical;
print $json->encode($conf);
}
sub _getKey {
my ( $self, $key ) = @_;
my $sep = $self->sep;
@ -304,7 +311,7 @@ sub run {
}
$self->cfgNum( $self->lastCfg ) unless ( $self->cfgNum );
my $action = shift;
unless ( $action =~ /^(?:get|set|addKey|delKey)$/ ) {
unless ( $action =~ /^(?:get|set|addKey|delKey|dump)$/ ) {
die
"unknown action $action. Only get, set, addKey or delKey are accepted";
}