From aaa15b9709cd58ad56e5008858867d91f4abe803 Mon Sep 17 00:00:00 2001 From: David Steele Date: Fri, 23 Apr 2021 11:46:03 -0400 Subject: [PATCH] Add help for all internal options valid for default roles. Fix the segfault when getting help for an internal option is requested by adding help for all internal options that are valid for a default command role. Also print warnings about internal options in code rather than putting in each command/option description. --- doc/lib/pgBackRestDoc/Common/DocConfig.pm | 29 +++-- doc/xml/reference.xml | 72 +++++++++-- doc/xml/release.xml | 13 ++ src/command/help/help.auto.c | 141 ++++++++++++++++++---- src/command/help/help.c | 29 +++-- test/src/module/command/helpTest.c | 16 ++- 6 files changed, 238 insertions(+), 62 deletions(-) diff --git a/doc/lib/pgBackRestDoc/Common/DocConfig.pm b/doc/lib/pgBackRestDoc/Common/DocConfig.pm index a08c92b61..4e6bf29b3 100644 --- a/doc/lib/pgBackRestDoc/Common/DocConfig.pm +++ b/doc/lib/pgBackRestDoc/Common/DocConfig.pm @@ -212,9 +212,6 @@ sub process foreach my $strOption (sort(keys(%{$oOptionDefine}))) { - # Skip options that are internal only for all commands (test options) - next if $oOptionDefine->{$strOption}{&CFGDEF_INTERNAL}; - # Iterate through all commands my @stryCommandList = sort(keys(%{defined($$oOptionDefine{$strOption}{&CFGDEF_COMMAND}) ? $$oOptionDefine{$strOption}{&CFGDEF_COMMAND} : $$oConfigHash{&CONFIG_HELP_COMMAND}})); @@ -233,9 +230,6 @@ sub process next; } - # Skip options that are internal only for the current command - next if $oOptionDefine->{$strOption}{&CFGDEF_COMMAND}{$strCommand}{&CFGDEF_INTERNAL}; - my $oCommandDoc = $oDoc->nodeGet('operation')->nodeGet('command-list')->nodeGetById('command', $strCommand); # First check if the option is documented in the command @@ -286,11 +280,14 @@ sub process # If a section is specified then use it, otherwise the option should be general since it is not for a specific # command - $strSection = $oOptionDoc->paramGet('section', false); - - if (!defined($strSection)) + if (defined($oOptionDoc)) { - $strSection = "general"; + $strSection = $oOptionDoc->paramGet('section', false); + + if (!defined($strSection)) + { + $strSection = "general"; + } } } } @@ -321,6 +318,8 @@ sub process $$oCommandOption{&CONFIG_HELP_SUMMARY} = $oOptionDoc->nodeGet('summary')->textGet(); $$oCommandOption{&CONFIG_HELP_DESCRIPTION} = $oOptionDoc->textGet(); $$oCommandOption{&CONFIG_HELP_EXAMPLE} = $oOptionDoc->fieldGet('example'); + $oCommandOption->{&CONFIG_HELP_INTERNAL} = + cfgDefineCommand()->{$strCommand}{&CFGDEF_INTERNAL} ? true : $oOptionDefine->{$strOption}{&CFGDEF_INTERNAL}; $$oCommandOption{&CONFIG_HELP_NAME} = $oOptionDoc->paramGet('name'); @@ -364,6 +363,7 @@ sub process $oOption->{&CONFIG_HELP_NAME_ALT} = $oCommandOption->{&CONFIG_HELP_NAME_ALT}; $$oOption{&CONFIG_HELP_DESCRIPTION} = $$oCommandOption{&CONFIG_HELP_DESCRIPTION}; $$oOption{&CONFIG_HELP_EXAMPLE} = $oOptionDoc->fieldGet('example'); + $oOption->{&CONFIG_HELP_INTERNAL} = $oOptionDefine->{$strOption}{&CFGDEF_INTERNAL}; } } } @@ -456,6 +456,9 @@ sub manGet foreach my $strOption (sort(keys(%{$$hConfig{&CONFIG_HELP_OPTION}}))) { + # Skip internal options + next if $hConfig->{&CONFIG_HELP_OPTION}{$strOption}{&CONFIG_HELP_INTERNAL}; + my $hOption = $$hConfig{&CONFIG_HELP_OPTION}{$strOption}; $iOptionMaxLen = length($strOption) > $iOptionMaxLen ? length($strOption) : $iOptionMaxLen; my $strSection = defined($$hOption{&CONFIG_HELP_SECTION}) ? $$hOption{&CONFIG_HELP_SECTION} : CFGDEF_GENERAL; @@ -642,6 +645,9 @@ sub helpConfigDocGet foreach my $strOption (sort(keys(%{$$oSectionHash{$strSection}}))) { + # Skip internal options + next if $oConfigHash->{&CONFIG_HELP_OPTION}{$strOption}{&CONFIG_HELP_INTERNAL}; + $self->helpOptionGet(undef, $strOption, $oSectionElement, $$oConfigHash{&CONFIG_HELP_OPTION}{$strOption}); } } @@ -708,6 +714,9 @@ sub helpCommandDocGet foreach my $strOption (sort(keys(%{$$oCommandHash{&CONFIG_HELP_OPTION}}))) { + # Skip internal options + next if $rhConfigDefine->{$strOption}{&CFGDEF_INTERNAL}; + # Skip secure options that can't be defined on the command line next if ($rhConfigDefine->{$strOption}{&CFGDEF_SECURE}); diff --git a/doc/xml/reference.xml b/doc/xml/reference.xml index cc7429611..c9f651bfa 100644 --- a/doc/xml/reference.xml +++ b/doc/xml/reference.xml @@ -210,6 +210,24 @@ 120 + + + Retry count for local jobs. + + The number of retries for jobs run in the local process, e.g. file backup. + + 5 + + + + + Retry interval after first retry. + + The first retry is always performed immediately. This option specifies the interval to wait (in seconds) before performing each additional retry. + + 30 + + Path where lock files are stored. @@ -265,6 +283,15 @@ 630 + + + Socket blocking enable. + + Enable blocking on socket connections. + + y + + Keep-alive enable. @@ -488,6 +515,15 @@ y + + + Repository is local. + + Indicates that the repository for the specified index is local and any repository host settings for that index (e.g. repo1-host) should be ignored. + + y + + Path where backups and archive are stored. @@ -1096,6 +1132,15 @@ backupdb + + + is local. + + Indicates that for the specified index is local and any host settings for that index (e.g. pg1-host) should be ignored. + + y + + data directory. @@ -1167,9 +1212,7 @@ @@ -1212,6 +1255,17 @@ y + + +