You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-07-30 19:23:04 +03:00
Fix option validity by role and make sections conform to C help.
The HTML command reference was showing some options that were not valid because it did not properly understand the new role validity system. Also, the custom section for the new repo option was not being honored. This is a bit messy because it leads to some duplicated code in help.c but there doesn't seem to be any way to fix that with the Perl data structures as they are. This code is being migrated to C so it doesn't seem worth messing with it too much with the risk of breaking other things.
This commit is contained in:
@ -226,8 +226,9 @@ sub process
|
||||
next;
|
||||
}
|
||||
|
||||
if (ref(\$$oOptionDefine{$strOption}{&CFGDEF_COMMAND}{$strCommand}) eq 'SCALAR' &&
|
||||
$$oOptionDefine{$strOption}{&CFGDEF_COMMAND}{$strCommand} == false)
|
||||
# Skip the option if it is not valid for this command and the default role. Only options valid for the default role are
|
||||
# show in help because that is the only role available to a user.
|
||||
if (!defined($oOptionDefine->{$strOption}{&CFGDEF_COMMAND}{$strCommand}{&CFGDEF_COMMAND_ROLE}{&CFGCMD_ROLE_DEFAULT}))
|
||||
{
|
||||
next;
|
||||
}
|
||||
@ -281,10 +282,16 @@ sub process
|
||||
{
|
||||
$oOptionDoc = $oDoc->nodeGet('operation')->nodeGet('operation-general')->nodeGet('option-list')
|
||||
->nodeGetById('option', $strOption, false);
|
||||
$strOptionSource = CONFIG_HELP_SOURCE_DEFAULT if (defined($oOptionDoc));
|
||||
|
||||
# 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);
|
||||
|
||||
$strOptionSource = CONFIG_HELP_SOURCE_DEFAULT if (defined($oOptionDoc));
|
||||
if (!defined($strSection))
|
||||
{
|
||||
$strSection = "general";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -745,28 +752,23 @@ sub helpCommandDocGetOptionFind
|
||||
my $strCommand = shift;
|
||||
my $strOption = shift;
|
||||
|
||||
my $strSection = CONFIG_HELP_COMMAND;
|
||||
# Get section from the option
|
||||
my $strSection = $oConfigHelpData->{&CONFIG_HELP_OPTION}{$strOption}{&CONFIG_HELP_SECTION};
|
||||
|
||||
# Get option from the command to start
|
||||
my $oOption = $$oConfigHelpData{&CONFIG_HELP_COMMAND}{$strCommand}{&CONFIG_HELP_OPTION}{$strOption};
|
||||
|
||||
if ($$oOption{&CONFIG_HELP_SOURCE} eq CONFIG_HELP_SOURCE_DEFAULT)
|
||||
{
|
||||
$strSection = CFGDEF_GENERAL;
|
||||
}
|
||||
elsif ($$oOption{&CONFIG_HELP_SOURCE} eq CONFIG_HELP_SOURCE_SECTION)
|
||||
# If the option has a section (i.e. not command-line only) then it comes from the standard option reference
|
||||
if ($$oOption{&CONFIG_HELP_SOURCE} eq CONFIG_HELP_SOURCE_SECTION)
|
||||
{
|
||||
$oOption = $$oConfigHelpData{&CONFIG_HELP_OPTION}{$strOption};
|
||||
}
|
||||
|
||||
if (defined($$oOption{&CONFIG_HELP_SECTION}) && $strSection ne $strCommand)
|
||||
{
|
||||
$strSection = $$oOption{&CONFIG_HELP_SECTION};
|
||||
}
|
||||
|
||||
if (($strSection ne CFGDEF_GENERAL && $strSection ne CFGDEF_LOG &&
|
||||
$strSection ne CFGDEF_REPOSITORY && $strSection ne CFGDEF_SECTION_STANZA) ||
|
||||
$strSection eq $strCommand)
|
||||
{
|
||||
$strSection = CONFIG_HELP_COMMAND;
|
||||
}
|
||||
# Reduce the sections that are shown in the command help. This is the same logic as help.c.
|
||||
if (!defined($strSection) ||
|
||||
($strSection ne 'general' && $strSection ne 'log' && $strSection ne 'repository' && $strSection ne 'stanza'))
|
||||
{
|
||||
$strSection = 'command';
|
||||
}
|
||||
|
||||
return $oOption, $strSection;
|
||||
|
Reference in New Issue
Block a user