From 15d04ca19c0bd1aafe9d4389e8429bcc392e842d Mon Sep 17 00:00:00 2001 From: David Steele Date: Thu, 12 Sep 2019 16:29:50 -0400 Subject: [PATCH] Add recursion and json output to the ls command. These features finally make the ls command practical. Currently the JSON contains only name, type, and size. We may add more fields in the future, but these seem like the minimum needed to be useful. --- build/lib/pgBackRestBuild/Config/Data.pm | 37 ++++-- doc/xml/reference.xml | 25 +++- lib/pgBackRest/LibCAuto.pm | 8 ++ src/Makefile.in | 2 +- src/command/storage/list.c | 152 ++++++++++++++++++++--- src/config/config.auto.c | 9 ++ src/config/config.auto.h | 5 +- src/config/define.auto.c | 63 +++++++++- src/config/define.auto.h | 1 + src/config/parse.auto.c | 8 ++ src/perl/embed.auto.c | 8 ++ test/src/module/command/storageTest.c | 126 ++++++++++++++++--- 12 files changed, 397 insertions(+), 47 deletions(-) diff --git a/build/lib/pgBackRestBuild/Config/Data.pm b/build/lib/pgBackRestBuild/Config/Data.pm index b17e1daf4..68cd9cebb 100644 --- a/build/lib/pgBackRestBuild/Config/Data.pm +++ b/build/lib/pgBackRestBuild/Config/Data.pm @@ -163,6 +163,8 @@ use constant CFGOPT_HOST_ID => 'host-id' #----------------------------------------------------------------------------------------------------------------------------------- use constant CFGOPT_FILTER => 'filter'; push @EXPORT, qw(CFGOPT_FILTER); +use constant CFGOPT_RECURSE => 'recurse'; + push @EXPORT, qw(CFGOPT_RECURSE); use constant CFGOPT_SORT => 'sort'; push @EXPORT, qw(CFGOPT_SORT); @@ -415,10 +417,10 @@ use constant CFGOPTVAL_REPO_CIPHER_TYPE_AES_256_CBC => 'aes-256- # Info output #----------------------------------------------------------------------------------------------------------------------------------- -use constant CFGOPTVAL_INFO_OUTPUT_TEXT => 'text'; - push @EXPORT, qw(CFGOPTVAL_INFO_OUTPUT_TEXT); -use constant CFGOPTVAL_INFO_OUTPUT_JSON => 'json'; - push @EXPORT, qw(CFGOPTVAL_INFO_OUTPUT_JSON); +use constant CFGOPTVAL_OUTPUT_TEXT => 'text'; + push @EXPORT, qw(CFGOPTVAL_OUTPUT_TEXT); +use constant CFGOPTVAL_OUTPUT_JSON => 'json'; + push @EXPORT, qw(CFGOPTVAL_OUTPUT_JSON); # Restore type #----------------------------------------------------------------------------------------------------------------------------------- @@ -1013,11 +1015,21 @@ my %hConfigDefine = { &CFGCMD_INFO => { - &CFGDEF_DEFAULT => CFGOPTVAL_INFO_OUTPUT_TEXT, + &CFGDEF_DEFAULT => CFGOPTVAL_OUTPUT_TEXT, &CFGDEF_ALLOW_LIST => [ - &CFGOPTVAL_INFO_OUTPUT_TEXT, - &CFGOPTVAL_INFO_OUTPUT_JSON, + &CFGOPTVAL_OUTPUT_TEXT, + &CFGOPTVAL_OUTPUT_JSON, + ] + }, + + &CFGCMD_STORAGE_LIST => + { + &CFGDEF_DEFAULT => CFGOPTVAL_OUTPUT_TEXT, + &CFGDEF_ALLOW_LIST => + [ + &CFGOPTVAL_OUTPUT_TEXT, + &CFGOPTVAL_OUTPUT_JSON, ] } } @@ -1085,12 +1097,23 @@ my %hConfigDefine = } }, + &CFGOPT_RECURSE => + { + &CFGDEF_TYPE => CFGDEF_TYPE_BOOLEAN, + &CFGDEF_DEFAULT => false, + &CFGDEF_COMMAND => + { + &CFGCMD_STORAGE_LIST => {}, + } + }, + &CFGOPT_SORT => { &CFGDEF_TYPE => CFGDEF_TYPE_STRING, &CFGDEF_DEFAULT => 'asc', &CFGDEF_ALLOW_LIST => [ + 'none', 'asc', 'desc', ], diff --git a/doc/xml/reference.xml b/doc/xml/reference.xml index 3e089f039..65babd1db 100644 --- a/doc/xml/reference.xml +++ b/doc/xml/reference.xml @@ -1243,14 +1243,37 @@ (F|D|I)$ + + + + + +