2015-09-08 13:31:24 +02:00
|
|
|
####################################################################################################################################
|
|
|
|
# DOC CONFIG MODULE
|
|
|
|
####################################################################################################################################
|
2015-10-28 11:10:36 +02:00
|
|
|
package BackRestDoc::Common::DocConfig;
|
2015-09-08 13:31:24 +02:00
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings FATAL => qw(all);
|
|
|
|
use Carp qw(confess);
|
|
|
|
|
|
|
|
use Exporter qw(import);
|
|
|
|
our @EXPORT = qw();
|
|
|
|
use File::Basename qw(dirname);
|
|
|
|
|
2016-04-14 15:30:54 +02:00
|
|
|
use pgBackRest::Common::Log;
|
|
|
|
use pgBackRest::Common::String;
|
2017-11-27 00:45:00 +02:00
|
|
|
use pgBackRestBuild::Config::Data;
|
2016-06-02 15:25:12 +02:00
|
|
|
use pgBackRest::Version;
|
2015-09-08 13:31:24 +02:00
|
|
|
|
2015-10-28 11:10:36 +02:00
|
|
|
####################################################################################################################################
|
|
|
|
# Help types
|
|
|
|
####################################################################################################################################
|
2017-08-25 22:47:47 +02:00
|
|
|
use constant CONFIG_HELP_COMMAND => 'command';
|
|
|
|
push @EXPORT, qw(CONFIG_HELP_COMMAND);
|
|
|
|
use constant CONFIG_HELP_CURRENT => 'current';
|
|
|
|
use constant CONFIG_HELP_DEFAULT => 'default';
|
|
|
|
use constant CONFIG_HELP_DESCRIPTION => 'description';
|
|
|
|
push @EXPORT, qw(CONFIG_HELP_DESCRIPTION);
|
2015-10-28 11:10:36 +02:00
|
|
|
use constant CONFIG_HELP_EXAMPLE => 'example';
|
2017-08-25 22:47:47 +02:00
|
|
|
use constant CONFIG_HELP_NAME => 'name';
|
2018-02-04 01:27:38 +02:00
|
|
|
use constant CONFIG_HELP_NAME_ALT => 'name-alt';
|
|
|
|
push @EXPORT, qw(CONFIG_HELP_NAME_ALT);
|
2017-08-25 22:47:47 +02:00
|
|
|
use constant CONFIG_HELP_OPTION => 'option';
|
|
|
|
push @EXPORT, qw(CONFIG_HELP_OPTION);
|
|
|
|
use constant CONFIG_HELP_SECTION => 'section';
|
2018-01-23 20:34:24 +02:00
|
|
|
push @EXPORT, qw(CONFIG_HELP_SECTION);
|
2017-08-25 22:47:47 +02:00
|
|
|
use constant CONFIG_HELP_SUMMARY => 'summary';
|
2018-01-23 20:34:24 +02:00
|
|
|
push @EXPORT, qw(CONFIG_HELP_SUMMARY);
|
2017-08-25 22:47:47 +02:00
|
|
|
|
|
|
|
use constant CONFIG_HELP_SOURCE => 'source';
|
2018-01-23 20:34:24 +02:00
|
|
|
push @EXPORT, qw(CONFIG_HELP_SOURCE);
|
2017-08-25 22:47:47 +02:00
|
|
|
use constant CONFIG_HELP_SOURCE_DEFAULT => 'default';
|
|
|
|
use constant CONFIG_HELP_SOURCE_SECTION => CONFIG_HELP_SECTION;
|
|
|
|
use constant CONFIG_HELP_SOURCE_COMMAND => CONFIG_HELP_COMMAND;
|
2018-01-23 20:34:24 +02:00
|
|
|
push @EXPORT, qw(CONFIG_HELP_SOURCE_COMMAND);
|
2017-08-25 22:47:47 +02:00
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# Config Section Types
|
|
|
|
####################################################################################################################################
|
|
|
|
use constant CFGDEF_COMMAND => 'command';
|
|
|
|
use constant CFGDEF_GENERAL => 'general';
|
|
|
|
use constant CFGDEF_LOG => 'log';
|
|
|
|
use constant CFGDEF_REPOSITORY => 'repository';
|
2015-09-08 13:31:24 +02:00
|
|
|
|
2017-11-02 14:14:13 +02:00
|
|
|
####################################################################################################################################
|
|
|
|
# Option define hash
|
|
|
|
####################################################################################################################################
|
|
|
|
my $rhConfigDefine = cfgDefine();
|
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# Returns the option defines based on the command.
|
|
|
|
####################################################################################################################################
|
|
|
|
sub docConfigCommandDefine
|
|
|
|
{
|
|
|
|
my $strOption = shift;
|
|
|
|
my $strCommand = shift;
|
|
|
|
|
|
|
|
if (defined($strCommand))
|
|
|
|
{
|
|
|
|
return defined($rhConfigDefine->{$strOption}{&CFGDEF_COMMAND}) &&
|
|
|
|
defined($rhConfigDefine->{$strOption}{&CFGDEF_COMMAND}{$strCommand}) &&
|
|
|
|
ref($rhConfigDefine->{$strOption}{&CFGDEF_COMMAND}{$strCommand}) eq 'HASH' ?
|
|
|
|
$rhConfigDefine->{$strOption}{&CFGDEF_COMMAND}{$strCommand} : undef;
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# Does the option have a default for this command?
|
|
|
|
####################################################################################################################################
|
|
|
|
sub docConfigOptionDefault
|
|
|
|
{
|
|
|
|
my $strOption = shift;
|
|
|
|
my $strCommand = shift;
|
|
|
|
|
|
|
|
# Get the command define
|
|
|
|
my $oCommandDefine = docConfigCommandDefine($strOption, $strCommand);
|
|
|
|
|
|
|
|
# Check for default in command
|
|
|
|
my $strDefault = defined($oCommandDefine) ? $$oCommandDefine{&CFGDEF_DEFAULT} : undef;
|
|
|
|
|
|
|
|
# If defined return, else try to grab the global default
|
|
|
|
return defined($strDefault) ? $strDefault : $rhConfigDefine->{$strOption}{&CFGDEF_DEFAULT};
|
|
|
|
}
|
|
|
|
|
|
|
|
push @EXPORT, qw(docConfigOptionDefault);
|
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# Get the allowed setting range for the option if it exists
|
|
|
|
####################################################################################################################################
|
|
|
|
sub docConfigOptionRange
|
|
|
|
{
|
|
|
|
my $strOption = shift;
|
|
|
|
my $strCommand = shift;
|
|
|
|
|
|
|
|
# Get the command define
|
|
|
|
my $oCommandDefine = docConfigCommandDefine($strOption, $strCommand);
|
|
|
|
|
|
|
|
# Check for default in command
|
|
|
|
if (defined($oCommandDefine) && defined($$oCommandDefine{&CFGDEF_ALLOW_RANGE}))
|
|
|
|
{
|
|
|
|
return $$oCommandDefine{&CFGDEF_ALLOW_RANGE}[0], $$oCommandDefine{&CFGDEF_ALLOW_RANGE}[1];
|
|
|
|
}
|
|
|
|
|
|
|
|
# If defined return, else try to grab the global default
|
|
|
|
return $rhConfigDefine->{$strOption}{&CFGDEF_ALLOW_RANGE}[0], $rhConfigDefine->{$strOption}{&CFGDEF_ALLOW_RANGE}[1];
|
|
|
|
}
|
|
|
|
|
|
|
|
push @EXPORT, qw(docConfigOptionRange);
|
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# Get the option type
|
|
|
|
####################################################################################################################################
|
|
|
|
sub docConfigOptionType
|
|
|
|
{
|
|
|
|
my $strOption = shift;
|
|
|
|
|
|
|
|
return $rhConfigDefine->{$strOption}{&CFGDEF_TYPE};
|
|
|
|
}
|
|
|
|
|
|
|
|
push @EXPORT, qw(docConfigOptionType);
|
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# Test the option type
|
|
|
|
####################################################################################################################################
|
|
|
|
sub docConfigOptionTypeTest
|
|
|
|
{
|
|
|
|
my $strOption = shift;
|
|
|
|
my $strType = shift;
|
|
|
|
|
|
|
|
return docConfigOptionType($strOption) eq $strType;
|
|
|
|
}
|
|
|
|
|
|
|
|
push @EXPORT, qw(docConfigOptionTypeTest);
|
|
|
|
|
2015-09-08 13:31:24 +02:00
|
|
|
####################################################################################################################################
|
|
|
|
# CONSTRUCTOR
|
|
|
|
####################################################################################################################################
|
|
|
|
sub new
|
|
|
|
{
|
|
|
|
my $class = shift; # Class name
|
|
|
|
|
|
|
|
# Create the class hash
|
|
|
|
my $self = {};
|
|
|
|
bless $self, $class;
|
|
|
|
|
|
|
|
# Assign function parameters, defaults, and log debug info
|
|
|
|
(
|
|
|
|
my $strOperation,
|
|
|
|
$self->{oDoc},
|
|
|
|
$self->{oDocRender}
|
|
|
|
) =
|
|
|
|
logDebugParam
|
|
|
|
(
|
2016-05-26 15:09:42 +02:00
|
|
|
__PACKAGE__ . '->new', \@_,
|
2015-09-08 13:31:24 +02:00
|
|
|
{name => 'oDoc'},
|
2017-08-25 22:47:47 +02:00
|
|
|
{name => 'oDocRender', required => false}
|
2015-09-08 13:31:24 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
$self->process();
|
|
|
|
|
|
|
|
# Return from function and log return values if any
|
|
|
|
return logDebugReturn
|
|
|
|
(
|
|
|
|
$strOperation,
|
|
|
|
{name => 'self', value => $self}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# process
|
|
|
|
#
|
|
|
|
# Parse the xml doc into commands and options.
|
|
|
|
####################################################################################################################################
|
|
|
|
sub process
|
|
|
|
{
|
|
|
|
my $self = shift;
|
|
|
|
|
|
|
|
# Assign function parameters, defaults, and log debug info
|
2016-05-26 15:09:42 +02:00
|
|
|
my $strOperation = logDebugParam(__PACKAGE__ . '->process');
|
2015-09-08 13:31:24 +02:00
|
|
|
|
|
|
|
# Iterate through all commands
|
|
|
|
my $oDoc = $self->{oDoc};
|
|
|
|
my $oConfigHash = {};
|
|
|
|
|
2017-11-02 14:14:13 +02:00
|
|
|
foreach my $strCommand (cfgDefineCommandList())
|
2015-09-08 13:31:24 +02:00
|
|
|
{
|
2017-08-25 22:47:47 +02:00
|
|
|
if ($strCommand eq CFGCMD_REMOTE || $strCommand eq CFGCMD_LOCAL)
|
2015-09-08 13:31:24 +02:00
|
|
|
{
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
|
|
|
my $oCommandDoc = $oDoc->nodeGet('operation')->nodeGet('command-list')->nodeGetById('command', $strCommand);
|
|
|
|
|
|
|
|
$$oConfigHash{&CONFIG_HELP_COMMAND}{$strCommand} = {};
|
|
|
|
my $oCommand = $$oConfigHash{&CONFIG_HELP_COMMAND}{$strCommand};
|
|
|
|
|
|
|
|
$$oCommand{&CONFIG_HELP_SUMMARY} = $oCommandDoc->nodeGet('summary')->textGet();
|
|
|
|
$$oCommand{&CONFIG_HELP_DESCRIPTION} = $oCommandDoc->textGet();
|
|
|
|
}
|
|
|
|
|
|
|
|
# Iterate through all options
|
2017-11-02 14:14:13 +02:00
|
|
|
my $oOptionDefine = cfgDefine();
|
2015-09-08 13:31:24 +02:00
|
|
|
|
2017-11-02 14:14:13 +02:00
|
|
|
foreach my $strOption (sort(keys(%{$oOptionDefine})))
|
2015-09-08 13:31:24 +02:00
|
|
|
{
|
2017-12-05 21:46:52 +02:00
|
|
|
# Skip options that are internal only for all commands (test options)
|
|
|
|
next if $oOptionDefine->{$strOption}{&CFGDEF_INTERNAL};
|
2015-09-08 13:31:24 +02:00
|
|
|
|
|
|
|
# Iterate through all commands
|
2017-11-02 14:14:13 +02:00
|
|
|
my @stryCommandList = sort(keys(%{defined($$oOptionDefine{$strOption}{&CFGDEF_COMMAND}) ?
|
|
|
|
$$oOptionDefine{$strOption}{&CFGDEF_COMMAND} : $$oConfigHash{&CONFIG_HELP_COMMAND}}));
|
2015-09-08 13:31:24 +02:00
|
|
|
|
|
|
|
foreach my $strCommand (@stryCommandList)
|
|
|
|
{
|
|
|
|
if (!defined($$oConfigHash{&CONFIG_HELP_COMMAND}{$strCommand}))
|
|
|
|
{
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
2017-11-02 14:14:13 +02:00
|
|
|
if (ref(\$$oOptionDefine{$strOption}{&CFGDEF_COMMAND}{$strCommand}) eq 'SCALAR' &&
|
|
|
|
$$oOptionDefine{$strOption}{&CFGDEF_COMMAND}{$strCommand} == false)
|
2015-09-09 21:40:54 +02:00
|
|
|
{
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
2017-12-05 21:46:52 +02:00
|
|
|
# Skip options that are internal only for the current command
|
|
|
|
next if $oOptionDefine->{$strOption}{&CFGDEF_COMMAND}{$strCommand}{&CFGDEF_INTERNAL};
|
|
|
|
|
2015-09-08 13:31:24 +02:00
|
|
|
my $oCommandDoc = $oDoc->nodeGet('operation')->nodeGet('command-list')->nodeGetById('command', $strCommand);
|
|
|
|
|
|
|
|
# First check if the option is documented in the command
|
|
|
|
my $oOptionDoc;
|
|
|
|
my $strOptionSource;
|
|
|
|
my $oCommandOptionList = $oCommandDoc->nodeGet('option-list', false);
|
|
|
|
|
|
|
|
if (defined($oCommandOptionList))
|
|
|
|
{
|
|
|
|
$oOptionDoc = $oCommandOptionList->nodeGetById('option', $strOption, false);
|
|
|
|
|
|
|
|
$strOptionSource = CONFIG_HELP_SOURCE_COMMAND if (defined($oOptionDoc));
|
|
|
|
}
|
|
|
|
|
|
|
|
# If the option wasn't found keep looking
|
|
|
|
my $strSection;
|
|
|
|
|
|
|
|
if (!defined($oOptionDoc))
|
|
|
|
{
|
|
|
|
# Next see if it's documented in the section
|
2017-11-02 14:14:13 +02:00
|
|
|
if (defined($$oOptionDefine{$strOption}{&CFGDEF_SECTION}))
|
2015-09-08 13:31:24 +02:00
|
|
|
{
|
2016-04-14 15:30:54 +02:00
|
|
|
# &log(INFO, " trying section ${strSection}");
|
|
|
|
foreach my $oSectionNode ($oDoc->nodeGet('config')->nodeGet('config-section-list')->nodeList())
|
2015-09-08 13:31:24 +02:00
|
|
|
{
|
2016-04-14 15:30:54 +02:00
|
|
|
my $oOptionDocCheck = $oSectionNode->nodeGetById('config-key-list')
|
|
|
|
->nodeGetById('config-key', $strOption, false);
|
|
|
|
|
|
|
|
if ($oOptionDocCheck)
|
2015-09-08 13:31:24 +02:00
|
|
|
{
|
2016-04-14 15:30:54 +02:00
|
|
|
if (defined($oOptionDoc))
|
|
|
|
{
|
|
|
|
confess 'option exists in more than one section';
|
|
|
|
}
|
|
|
|
|
|
|
|
$oOptionDoc = $oOptionDocCheck;
|
|
|
|
$strOptionSource = CONFIG_HELP_SOURCE_SECTION;
|
|
|
|
$strSection = $oSectionNode->paramGet('id');
|
2015-09-08 13:31:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
# If no section is defined then look in the default command option list
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$oOptionDoc = $oDoc->nodeGet('operation')->nodeGet('operation-general')->nodeGet('option-list')
|
|
|
|
->nodeGetById('option', $strOption, false);
|
|
|
|
|
|
|
|
$strOptionSource = CONFIG_HELP_SOURCE_DEFAULT if (defined($oOptionDoc));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# If the option wasn't found then error
|
|
|
|
if (!defined($oOptionDoc))
|
|
|
|
{
|
|
|
|
confess &log(ERROR, "unable to find option '${strOption}' for command '${strCommand}'")
|
|
|
|
}
|
|
|
|
|
2016-04-14 15:30:54 +02:00
|
|
|
# if the option is documented in the command then it should be accessible from the command line only.
|
|
|
|
if (!defined($strSection))
|
|
|
|
{
|
2017-11-02 14:14:13 +02:00
|
|
|
if (defined($$oOptionDefine{$strOption}{&CFGDEF_SECTION}))
|
2016-04-14 15:30:54 +02:00
|
|
|
{
|
2017-08-25 22:47:47 +02:00
|
|
|
&log(ERROR,
|
2017-11-02 14:14:13 +02:00
|
|
|
"option ${strOption} defined in command ${strCommand} must not have " . CFGDEF_SECTION .
|
2017-08-25 22:47:47 +02:00
|
|
|
" defined");
|
2016-04-14 15:30:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-08 13:31:24 +02:00
|
|
|
# Store the option in the command
|
2017-08-25 22:47:47 +02:00
|
|
|
$$oConfigHash{&CONFIG_HELP_COMMAND}{$strCommand}{&CONFIG_HELP_OPTION}{$strOption}{&CONFIG_HELP_SOURCE} =
|
|
|
|
$strOptionSource;
|
2015-09-08 13:31:24 +02:00
|
|
|
|
|
|
|
my $oCommandOption = $$oConfigHash{&CONFIG_HELP_COMMAND}{$strCommand}{&CONFIG_HELP_OPTION}{$strOption};
|
|
|
|
|
|
|
|
$$oCommandOption{&CONFIG_HELP_SUMMARY} = $oOptionDoc->nodeGet('summary')->textGet();
|
|
|
|
$$oCommandOption{&CONFIG_HELP_DESCRIPTION} = $oOptionDoc->textGet();
|
2015-10-28 11:10:36 +02:00
|
|
|
$$oCommandOption{&CONFIG_HELP_EXAMPLE} = $oOptionDoc->fieldGet('example');
|
|
|
|
|
|
|
|
$$oCommandOption{&CONFIG_HELP_NAME} = $oOptionDoc->paramGet('name');
|
2015-09-08 13:31:24 +02:00
|
|
|
|
2018-02-04 01:27:38 +02:00
|
|
|
# Generate a list of alternate names
|
|
|
|
if (defined($rhConfigDefine->{$strOption}{&CFGDEF_NAME_ALT}))
|
|
|
|
{
|
|
|
|
my $rhNameAlt = {};
|
|
|
|
|
|
|
|
foreach my $strNameAlt (sort(keys(%{$rhConfigDefine->{$strOption}{&CFGDEF_NAME_ALT}})))
|
|
|
|
{
|
|
|
|
$strNameAlt =~ s/\?//g;
|
|
|
|
|
|
|
|
if ($strNameAlt ne $strOption)
|
|
|
|
{
|
|
|
|
$rhNameAlt->{$strNameAlt} = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
my @stryNameAlt = sort(keys(%{$rhNameAlt}));
|
|
|
|
|
|
|
|
if (@stryNameAlt > 0)
|
|
|
|
{
|
|
|
|
$oCommandOption->{&CONFIG_HELP_NAME_ALT} = \@stryNameAlt;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-08 13:31:24 +02:00
|
|
|
# If the option did not come from the command also store in global option list. This prevents duplication of commonly
|
|
|
|
# used options.
|
|
|
|
if ($strOptionSource ne CONFIG_HELP_SOURCE_COMMAND)
|
|
|
|
{
|
|
|
|
$$oConfigHash{&CONFIG_HELP_OPTION}{$strOption}{&CONFIG_HELP_SUMMARY} = $$oCommandOption{&CONFIG_HELP_SUMMARY};
|
|
|
|
|
|
|
|
my $oOption = $$oConfigHash{&CONFIG_HELP_OPTION}{$strOption};
|
|
|
|
|
|
|
|
if (defined($strSection))
|
|
|
|
{
|
|
|
|
$$oOption{&CONFIG_HELP_SECTION} = $strSection;
|
|
|
|
}
|
|
|
|
|
2015-10-28 11:10:36 +02:00
|
|
|
$$oOption{&CONFIG_HELP_NAME} = $oOptionDoc->paramGet('name');
|
2018-02-04 01:27:38 +02:00
|
|
|
$oOption->{&CONFIG_HELP_NAME_ALT} = $oCommandOption->{&CONFIG_HELP_NAME_ALT};
|
2015-09-08 13:31:24 +02:00
|
|
|
$$oOption{&CONFIG_HELP_DESCRIPTION} = $$oCommandOption{&CONFIG_HELP_DESCRIPTION};
|
2015-10-28 11:10:36 +02:00
|
|
|
$$oOption{&CONFIG_HELP_EXAMPLE} = $oOptionDoc->fieldGet('example');
|
2015-09-08 13:31:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Store the config hash
|
|
|
|
$self->{oConfigHash} = $oConfigHash;
|
|
|
|
|
|
|
|
# Return from function and log return values if any
|
|
|
|
logDebugReturn($strOperation);
|
|
|
|
}
|
|
|
|
|
2015-10-28 11:10:36 +02:00
|
|
|
####################################################################################################################################
|
2016-06-02 15:25:12 +02:00
|
|
|
# manGet
|
|
|
|
#
|
|
|
|
# Generate the man page.
|
|
|
|
####################################################################################################################################
|
|
|
|
sub manGet
|
|
|
|
{
|
|
|
|
my $self = shift;
|
|
|
|
|
|
|
|
# Assign function parameters, defaults, and log debug info
|
|
|
|
my
|
|
|
|
(
|
|
|
|
$strOperation,
|
|
|
|
$oManifest
|
|
|
|
) =
|
|
|
|
logDebugParam
|
|
|
|
(
|
|
|
|
__PACKAGE__ . '->manGet', \@_,
|
|
|
|
{name => 'oManifest'}
|
|
|
|
);
|
|
|
|
|
|
|
|
# Get index.xml to pull various text from
|
|
|
|
my $oIndexDoc = ${$oManifest->sourceGet('index')}{doc};
|
|
|
|
|
|
|
|
# Write the header
|
|
|
|
my $strManPage =
|
|
|
|
"NAME\n" .
|
|
|
|
' ' . BACKREST_NAME . ' - ' . $oManifest->variableReplace($oIndexDoc->paramGet('subtitle')) . "\n\n" .
|
|
|
|
"SYNOPSIS\n" .
|
|
|
|
' ' . BACKREST_EXE . ' [options] [command]';
|
|
|
|
|
|
|
|
# Output the description (first two paragraphs of index.xml introduction)
|
|
|
|
my $iParaTotal = 0;
|
|
|
|
|
|
|
|
$strManPage .= "\n\n" .
|
|
|
|
"DESCRIPTION";
|
|
|
|
|
|
|
|
foreach my $oPara ($oIndexDoc->nodeGetById('section', 'introduction')->nodeList('p'))
|
|
|
|
{
|
|
|
|
if ($iParaTotal >= 2)
|
|
|
|
{
|
|
|
|
last;
|
|
|
|
}
|
|
|
|
|
|
|
|
$strManPage .= ($iParaTotal == 0 ? "\n" : "\n\n") . ' ' .
|
|
|
|
manGetFormatText($oManifest->variableReplace($self->{oDocRender}->processText($oPara->textGet())), 80, 2);
|
|
|
|
|
|
|
|
$iParaTotal++;
|
|
|
|
}
|
|
|
|
|
|
|
|
# Build command and config hashes
|
2017-11-02 14:14:13 +02:00
|
|
|
my $hConfigDefine = cfgDefine();
|
2016-06-02 15:25:12 +02:00
|
|
|
my $hConfig = $self->{oConfigHash};
|
|
|
|
my $hCommandList = {};
|
|
|
|
my $iCommandMaxLen = 0;
|
|
|
|
my $hOptionList = {};
|
|
|
|
my $iOptionMaxLen = 0;
|
|
|
|
|
|
|
|
foreach my $strCommand (sort(keys(%{$$hConfig{&CONFIG_HELP_COMMAND}})))
|
|
|
|
{
|
|
|
|
my $hCommand = $$hConfig{&CONFIG_HELP_COMMAND}{$strCommand};
|
|
|
|
$iCommandMaxLen = length($strCommand) > $iCommandMaxLen ? length($strCommand) : $iCommandMaxLen;
|
|
|
|
|
|
|
|
$$hCommandList{$strCommand}{summary} = $$hCommand{&CONFIG_HELP_SUMMARY};
|
|
|
|
|
|
|
|
if (defined($$hCommand{&CONFIG_HELP_OPTION}))
|
|
|
|
{
|
|
|
|
foreach my $strOption (sort(keys(%{$$hCommand{&CONFIG_HELP_OPTION}})))
|
|
|
|
{
|
|
|
|
my $hOption = $$hCommand{&CONFIG_HELP_OPTION}{$strOption};
|
|
|
|
|
|
|
|
if ($$hOption{&CONFIG_HELP_SOURCE} eq CONFIG_HELP_SOURCE_COMMAND)
|
|
|
|
{
|
|
|
|
$iOptionMaxLen = length($strOption) > $iOptionMaxLen ? length($strOption) : $iOptionMaxLen;
|
|
|
|
|
|
|
|
$$hOptionList{$strCommand}{$strOption}{&CONFIG_HELP_SUMMARY} = $$hOption{&CONFIG_HELP_SUMMARY};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach my $strOption (sort(keys(%{$$hConfig{&CONFIG_HELP_OPTION}})))
|
|
|
|
{
|
|
|
|
my $hOption = $$hConfig{&CONFIG_HELP_OPTION}{$strOption};
|
|
|
|
$iOptionMaxLen = length($strOption) > $iOptionMaxLen ? length($strOption) : $iOptionMaxLen;
|
2017-08-25 22:47:47 +02:00
|
|
|
my $strSection = defined($$hOption{&CONFIG_HELP_SECTION}) ? $$hOption{&CONFIG_HELP_SECTION} : CFGDEF_GENERAL;
|
2016-06-02 15:25:12 +02:00
|
|
|
|
|
|
|
$$hOptionList{$strSection}{$strOption}{&CONFIG_HELP_SUMMARY} = $$hOption{&CONFIG_HELP_SUMMARY};
|
|
|
|
}
|
|
|
|
|
|
|
|
# Output Commands
|
|
|
|
$strManPage .= "\n\n" .
|
|
|
|
'COMMANDS';
|
|
|
|
|
|
|
|
foreach my $strCommand (sort(keys(%{$hCommandList})))
|
|
|
|
{
|
|
|
|
# Construct the summary
|
|
|
|
my $strSummary = $oManifest->variableReplace($self->{oDocRender}->processText($$hCommandList{$strCommand}{summary}));
|
|
|
|
# $strSummary = lcfirst(substr($strSummary, 0, length($strSummary) - 1));
|
|
|
|
|
|
|
|
# Output the summary
|
|
|
|
$strManPage .=
|
|
|
|
"\n " . "${strCommand}" . (' ' x ($iCommandMaxLen - length($strCommand))) . ' ' .
|
|
|
|
manGetFormatText($strSummary, 80, $iCommandMaxLen + 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
# Output options
|
|
|
|
my $bFirst = true;
|
|
|
|
$strManPage .= "\n\n" .
|
|
|
|
'OPTIONS';
|
|
|
|
|
|
|
|
foreach my $strSection (sort(keys(%{$hOptionList})))
|
|
|
|
{
|
|
|
|
$strManPage .= ($bFirst ?'' : "\n") . "\n " . ucfirst($strSection) . ' Options:';
|
|
|
|
|
|
|
|
foreach my $strOption (sort(keys(%{$$hOptionList{$strSection}})))
|
|
|
|
{
|
|
|
|
my $hOption = $$hOptionList{$strSection}{$strOption};
|
|
|
|
|
|
|
|
# Contruct the default
|
2017-11-02 14:14:13 +02:00
|
|
|
my $strCommand = grep(/$strSection/i, cfgDefineCommandList()) ? $strSection : undef;
|
|
|
|
my $strDefault = docConfigOptionDefault($strOption, $strCommand);
|
2016-06-02 15:25:12 +02:00
|
|
|
|
|
|
|
if (defined($strDefault))
|
|
|
|
{
|
2018-02-04 01:27:38 +02:00
|
|
|
if ($strOption eq CFGOPT_REPO_HOST_CMD || $strOption eq CFGOPT_PG_HOST_CMD)
|
2016-08-29 15:43:22 +02:00
|
|
|
{
|
|
|
|
$strDefault = BACKREST_EXE;
|
|
|
|
}
|
2017-11-02 14:14:13 +02:00
|
|
|
elsif ($$hConfigDefine{$strOption}{&CFGDEF_TYPE} eq &CFGDEF_TYPE_BOOLEAN)
|
2016-06-02 15:25:12 +02:00
|
|
|
{
|
|
|
|
$strDefault = $strDefault ? 'y' : 'n';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#
|
|
|
|
# use Data::Dumper; confess Dumper($$hOption{&CONFIG_HELP_SUMMARY});
|
|
|
|
|
|
|
|
# Construct the summary
|
|
|
|
my $strSummary = $oManifest->variableReplace($self->{oDocRender}->processText($$hOption{&CONFIG_HELP_SUMMARY}));
|
|
|
|
|
|
|
|
$strSummary = $strSummary . (defined($strDefault) ? " [default=${strDefault}]" : '');
|
|
|
|
|
|
|
|
# Output the summary
|
|
|
|
$strManPage .=
|
|
|
|
"\n " . "--${strOption}" . (' ' x ($iOptionMaxLen - length($strOption))) . ' ' .
|
|
|
|
manGetFormatText($strSummary, 80, $iOptionMaxLen + 8);
|
|
|
|
}
|
|
|
|
|
|
|
|
$bFirst = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
# Write files, examples, and references
|
|
|
|
$strManPage .= "\n\n" .
|
|
|
|
"FILES\n" .
|
|
|
|
"\n" .
|
2017-11-02 14:14:13 +02:00
|
|
|
' ' . docConfigOptionDefault(CFGOPT_CONFIG) . "\n" .
|
|
|
|
' ' . docConfigOptionDefault(CFGOPT_REPO_PATH) . "\n" .
|
|
|
|
' ' . docConfigOptionDefault(CFGOPT_LOG_PATH) . "\n" .
|
|
|
|
' ' . docConfigOptionDefault(CFGOPT_SPOOL_PATH) . "\n" .
|
|
|
|
' ' . docConfigOptionDefault(CFGOPT_LOCK_PATH) . "\n" .
|
2016-06-02 15:25:12 +02:00
|
|
|
"\n" .
|
|
|
|
"EXAMPLES\n" .
|
|
|
|
"\n" .
|
|
|
|
" * Create a backup of the PostgreSQL `main` cluster:\n" .
|
|
|
|
"\n" .
|
2017-08-25 22:47:47 +02:00
|
|
|
' $ ' . BACKREST_EXE . ' --' . CFGOPT_STANZA . "=main backup\n" .
|
2016-06-02 15:25:12 +02:00
|
|
|
"\n" .
|
2017-11-02 14:14:13 +02:00
|
|
|
' The `main` cluster should be configured in `' . docConfigOptionDefault(CFGOPT_CONFIG) . "`\n" .
|
2016-06-02 15:25:12 +02:00
|
|
|
"\n" .
|
|
|
|
" * Show all available backups:\n" .
|
|
|
|
"\n" .
|
2017-08-25 22:47:47 +02:00
|
|
|
' $ ' . BACKREST_EXE . ' ' . CFGCMD_INFO . "\n" .
|
2016-06-02 15:25:12 +02:00
|
|
|
"\n" .
|
|
|
|
" * Show all available backups for a specific cluster:\n" .
|
|
|
|
"\n" .
|
2017-08-25 22:47:47 +02:00
|
|
|
' $ ' . BACKREST_EXE . ' --' . CFGOPT_STANZA . '=main ' . CFGCMD_INFO . "\n" .
|
2016-06-02 15:25:12 +02:00
|
|
|
"\n" .
|
|
|
|
" * Show backup specific options:\n" .
|
|
|
|
"\n" .
|
2017-08-25 22:47:47 +02:00
|
|
|
' $ ' . BACKREST_EXE . ' ' . CFGCMD_HELP . ' ' . CFGCMD_BACKUP . "\n" .
|
2016-06-02 15:25:12 +02:00
|
|
|
"\n" .
|
|
|
|
"SEE ALSO\n" .
|
|
|
|
"\n" .
|
|
|
|
' /usr/share/doc/' . BACKREST_EXE . "-doc/html/index.html\n" .
|
|
|
|
' ' . $oManifest->variableReplace('{[backrest-url-base]}') . "\n";
|
|
|
|
|
|
|
|
return $strManPage;
|
|
|
|
}
|
|
|
|
|
|
|
|
# Helper function for manGet() used to format text by indenting and splitting
|
|
|
|
sub manGetFormatText
|
|
|
|
{
|
|
|
|
my $strLine = shift;
|
|
|
|
my $iLength = shift;
|
|
|
|
my $iIndentRest = shift;
|
|
|
|
|
|
|
|
my $strPart;
|
|
|
|
my $strResult;
|
|
|
|
my $bFirst = true;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
my $iIndent = $bFirst ? 0 : $iIndentRest;
|
|
|
|
|
|
|
|
($strPart, $strLine) = stringSplit($strLine, ' ', $iLength - $iIndentRest);
|
|
|
|
|
|
|
|
$strResult .= ($bFirst ? '' : "\n") . (' ' x $iIndent) . trim($strPart);
|
|
|
|
|
|
|
|
$bFirst = false;
|
|
|
|
}
|
|
|
|
while (defined($strLine));
|
|
|
|
|
|
|
|
return $strResult;
|
|
|
|
}
|
|
|
|
|
|
|
|
####################################################################################################################################
|
2015-10-28 11:10:36 +02:00
|
|
|
# helpConfigDocGet
|
|
|
|
#
|
|
|
|
# Get the xml for configuration help.
|
|
|
|
####################################################################################################################################
|
|
|
|
sub helpConfigDocGet
|
|
|
|
{
|
|
|
|
my $self = shift;
|
|
|
|
|
|
|
|
# Assign function parameters, defaults, and log debug info
|
2016-05-26 15:09:42 +02:00
|
|
|
my $strOperation = logDebugParam(__PACKAGE__ . '->helpConfigDocGet');
|
2015-10-28 11:10:36 +02:00
|
|
|
|
|
|
|
# Build a hash of the sections
|
|
|
|
my $oConfigHash = $self->{oConfigHash};
|
|
|
|
my $oConfigDoc = $self->{oDoc}->nodeGet('config');
|
|
|
|
my $oSectionHash = {};
|
|
|
|
|
2016-05-19 16:25:04 +02:00
|
|
|
foreach my $strOption (sort(keys(%{$$oConfigHash{&CONFIG_HELP_OPTION}})))
|
2015-10-28 11:10:36 +02:00
|
|
|
{
|
|
|
|
my $oOption = $$oConfigHash{&CONFIG_HELP_OPTION}{$strOption};
|
|
|
|
|
|
|
|
if (defined($$oOption{&CONFIG_HELP_SECTION}))
|
|
|
|
{
|
|
|
|
$$oSectionHash{$$oOption{&CONFIG_HELP_SECTION}}{$strOption} = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
my $oDoc = new BackRestDoc::Common::Doc();
|
|
|
|
$oDoc->paramSet('title', $oConfigDoc->paramGet('title'));
|
|
|
|
|
2016-05-16 23:01:48 +02:00
|
|
|
# set the description for use as a meta tag
|
|
|
|
$oDoc->fieldSet('description', $oConfigDoc->fieldGet('description'));
|
|
|
|
|
2015-10-28 11:10:36 +02:00
|
|
|
# Output the introduction
|
|
|
|
my $oIntroSectionDoc = $oDoc->nodeAdd('section', undef, {id => 'introduction'});
|
|
|
|
$oIntroSectionDoc->nodeAdd('title')->textSet('Introduction');
|
|
|
|
$oIntroSectionDoc->textSet($oConfigDoc->textGet());
|
|
|
|
|
2016-05-19 16:25:04 +02:00
|
|
|
foreach my $strSection (sort(keys(%{$oSectionHash})))
|
2015-10-28 11:10:36 +02:00
|
|
|
{
|
|
|
|
my $oSectionElement = $oDoc->nodeAdd('section', undef, {id => "section-${strSection}"});
|
|
|
|
|
|
|
|
my $oSectionDoc = $oConfigDoc->nodeGet('config-section-list')->nodeGetById('config-section', $strSection);
|
|
|
|
|
2017-08-16 22:54:35 +02:00
|
|
|
# Set the summary text for the section
|
|
|
|
$oSectionElement->textSet($oSectionDoc->textGet());
|
|
|
|
|
2015-10-28 11:10:36 +02:00
|
|
|
$oSectionElement->
|
|
|
|
nodeAdd('title')->textSet(
|
|
|
|
{name => 'text',
|
2016-04-14 15:30:54 +02:00
|
|
|
children=> [$oSectionDoc->paramGet('name') . ' Options (', {name => 'id', value => $strSection}, ')']});
|
2015-10-28 11:10:36 +02:00
|
|
|
|
2016-05-19 16:25:04 +02:00
|
|
|
foreach my $strOption (sort(keys(%{$$oSectionHash{$strSection}})))
|
2015-10-28 11:10:36 +02:00
|
|
|
{
|
|
|
|
$self->helpOptionGet(undef, $strOption, $oSectionElement, $$oConfigHash{&CONFIG_HELP_OPTION}{$strOption});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Return from function and log return values if any
|
|
|
|
return logDebugReturn
|
|
|
|
(
|
|
|
|
$strOperation,
|
|
|
|
{name => 'oDoc', value => $oDoc}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# helpCommandDocGet
|
|
|
|
#
|
|
|
|
# Get the xml for command help.
|
|
|
|
####################################################################################################################################
|
|
|
|
sub helpCommandDocGet
|
|
|
|
{
|
|
|
|
my $self = shift;
|
|
|
|
|
|
|
|
# Assign function parameters, defaults, and log debug info
|
2016-05-26 15:09:42 +02:00
|
|
|
my $strOperation = logDebugParam(__PACKAGE__ . '->helpCommandDocGet');
|
2015-10-28 11:10:36 +02:00
|
|
|
|
|
|
|
# Working variables
|
|
|
|
my $oConfigHash = $self->{oConfigHash};
|
|
|
|
my $oOperationDoc = $self->{oDoc}->nodeGet('operation');
|
2017-11-02 14:14:13 +02:00
|
|
|
my $oOptionDefine = cfgDefine();
|
2015-10-28 11:10:36 +02:00
|
|
|
|
|
|
|
my $oDoc = new BackRestDoc::Common::Doc();
|
|
|
|
$oDoc->paramSet('title', $oOperationDoc->paramGet('title'));
|
|
|
|
|
2016-05-16 23:01:48 +02:00
|
|
|
# set the description for use as a meta tag
|
|
|
|
$oDoc->fieldSet('description', $oOperationDoc->fieldGet('description'));
|
|
|
|
|
2015-10-28 11:10:36 +02:00
|
|
|
# Output the introduction
|
|
|
|
my $oIntroSectionDoc = $oDoc->nodeAdd('section', undef, {id => 'introduction'});
|
|
|
|
$oIntroSectionDoc->nodeAdd('title')->textSet('Introduction');
|
|
|
|
$oIntroSectionDoc->textSet($oOperationDoc->textGet());
|
|
|
|
|
2016-05-19 16:25:04 +02:00
|
|
|
foreach my $strCommand (sort(keys(%{$$oConfigHash{&CONFIG_HELP_COMMAND}})))
|
2015-10-28 11:10:36 +02:00
|
|
|
{
|
|
|
|
my $oCommandHash = $$oConfigHash{&CONFIG_HELP_COMMAND}{$strCommand};
|
|
|
|
my $oSectionElement = $oDoc->nodeAdd('section', undef, {id => "command-${strCommand}"});
|
|
|
|
|
|
|
|
my $oCommandDoc = $oOperationDoc->nodeGet('command-list')->nodeGetById('command', $strCommand);
|
|
|
|
|
|
|
|
$oSectionElement->
|
|
|
|
nodeAdd('title')->textSet(
|
|
|
|
{name => 'text',
|
|
|
|
children=> [$oCommandDoc->paramGet('name') . ' Command (', {name => 'id', value => $strCommand}, ')']});
|
|
|
|
|
|
|
|
$oSectionElement->textSet($$oCommandHash{&CONFIG_HELP_DESCRIPTION});
|
|
|
|
|
2016-05-26 15:34:03 +02:00
|
|
|
# use Data::doc;
|
2015-10-28 11:10:36 +02:00
|
|
|
# confess Dumper($oDoc->{oDoc});
|
|
|
|
|
|
|
|
if (defined($$oCommandHash{&CONFIG_HELP_OPTION}))
|
|
|
|
{
|
|
|
|
my $oCategory = {};
|
|
|
|
|
|
|
|
foreach my $strOption (sort(keys(%{$$oCommandHash{&CONFIG_HELP_OPTION}})))
|
|
|
|
{
|
2017-11-02 14:14:13 +02:00
|
|
|
my ($oOption, $strCategory) = helpCommandDocGetOptionFind($oConfigHash, $oOptionDefine, $strCommand, $strOption);
|
2015-10-28 11:10:36 +02:00
|
|
|
|
|
|
|
$$oCategory{$strCategory}{$strOption} = $oOption;
|
|
|
|
}
|
|
|
|
|
|
|
|
# Iterate sections
|
|
|
|
foreach my $strCategory (sort(keys(%{$oCategory})))
|
|
|
|
{
|
|
|
|
my $oOptionListElement = $oSectionElement->nodeAdd('section', undef, {id => "category-${strCategory}"});
|
|
|
|
|
|
|
|
$oOptionListElement->
|
|
|
|
nodeAdd('title')->textSet(ucfirst($strCategory) . ' Options');
|
|
|
|
|
|
|
|
# Iterate options
|
|
|
|
foreach my $strOption (sort(keys(%{$$oCategory{$strCategory}})))
|
|
|
|
{
|
|
|
|
$self->helpOptionGet($strCommand, $strOption, $oOptionListElement,
|
|
|
|
$$oCommandHash{&CONFIG_HELP_OPTION}{$strOption});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Return from function and log return values if any
|
|
|
|
return logDebugReturn
|
|
|
|
(
|
|
|
|
$strOperation,
|
|
|
|
{name => 'oDoc', value => $oDoc}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2016-02-23 16:25:22 +02:00
|
|
|
# Helper function for helpCommandDocGet() to find options. The option may be stored with the command or in the option list depending
|
|
|
|
# on whether it's generic or command-specific
|
|
|
|
sub helpCommandDocGetOptionFind
|
|
|
|
{
|
|
|
|
my $oConfigHelpData = shift;
|
2017-11-02 14:14:13 +02:00
|
|
|
my $oOptionDefine = shift;
|
2016-02-23 16:25:22 +02:00
|
|
|
my $strCommand = shift;
|
|
|
|
my $strOption = shift;
|
|
|
|
|
|
|
|
my $strSection = CONFIG_HELP_COMMAND;
|
|
|
|
my $oOption = $$oConfigHelpData{&CONFIG_HELP_COMMAND}{$strCommand}{&CONFIG_HELP_OPTION}{$strOption};
|
|
|
|
|
|
|
|
if ($$oOption{&CONFIG_HELP_SOURCE} eq CONFIG_HELP_SOURCE_DEFAULT)
|
|
|
|
{
|
2017-08-25 22:47:47 +02:00
|
|
|
$strSection = CFGDEF_GENERAL;
|
2016-02-23 16:25:22 +02:00
|
|
|
}
|
|
|
|
elsif ($$oOption{&CONFIG_HELP_SOURCE} eq CONFIG_HELP_SOURCE_SECTION)
|
|
|
|
{
|
|
|
|
$oOption = $$oConfigHelpData{&CONFIG_HELP_OPTION}{$strOption};
|
|
|
|
|
2017-07-26 15:33:10 +02:00
|
|
|
if (defined($$oOption{&CONFIG_HELP_SECTION}) && $strSection ne $strCommand)
|
2016-02-23 16:25:22 +02:00
|
|
|
{
|
|
|
|
$strSection = $$oOption{&CONFIG_HELP_SECTION};
|
|
|
|
}
|
|
|
|
|
2017-08-25 22:47:47 +02:00
|
|
|
if (($strSection ne CFGDEF_GENERAL && $strSection ne CFGDEF_LOG &&
|
2018-02-19 22:07:24 +02:00
|
|
|
$strSection ne CFGDEF_REPOSITORY && $strSection ne CFGDEF_SECTION_STANZA) ||
|
2017-07-26 15:33:10 +02:00
|
|
|
$strSection eq $strCommand)
|
2016-02-23 16:25:22 +02:00
|
|
|
{
|
|
|
|
$strSection = CONFIG_HELP_COMMAND;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $oOption, $strSection;
|
|
|
|
}
|
|
|
|
|
2015-10-28 11:10:36 +02:00
|
|
|
####################################################################################################################################
|
|
|
|
# helpOptionGet
|
|
|
|
#
|
|
|
|
# Get the xml for an option.
|
|
|
|
####################################################################################################################################
|
|
|
|
sub helpOptionGet
|
|
|
|
{
|
|
|
|
my $self = shift;
|
|
|
|
my $strCommand = shift;
|
|
|
|
my $strOption = shift;
|
|
|
|
my $oParentElement = shift;
|
|
|
|
my $oOptionHash = shift;
|
|
|
|
|
|
|
|
# Create the option section
|
|
|
|
my $oOptionElement = $oParentElement->nodeAdd('section', undef, {id => "option-${strOption}"});
|
|
|
|
|
|
|
|
# Set the option section title
|
|
|
|
$oOptionElement->
|
|
|
|
nodeAdd('title')->textSet(
|
|
|
|
{name => 'text',
|
|
|
|
children=> [$$oOptionHash{&CONFIG_HELP_NAME} . ' Option (', {name => 'id', value => "--${strOption}"}, ')']});
|
|
|
|
|
|
|
|
# Add the option summary and description
|
|
|
|
$oOptionElement->
|
|
|
|
nodeAdd('p')->textSet($$oOptionHash{&CONFIG_HELP_SUMMARY});
|
|
|
|
|
|
|
|
$oOptionElement->
|
|
|
|
nodeAdd('p')->textSet($$oOptionHash{&CONFIG_HELP_DESCRIPTION});
|
|
|
|
|
|
|
|
# Get the default value (or required=n if there is no default)
|
|
|
|
my $strCodeBlock;
|
|
|
|
|
2017-11-02 14:14:13 +02:00
|
|
|
if (defined(docConfigOptionDefault($strOption, $strCommand)))
|
2015-10-28 11:10:36 +02:00
|
|
|
{
|
|
|
|
my $strDefault;
|
|
|
|
|
2018-02-04 01:27:38 +02:00
|
|
|
if ($strOption eq CFGOPT_REPO_HOST_CMD || $strOption eq CFGOPT_PG_HOST_CMD)
|
2015-10-28 11:10:36 +02:00
|
|
|
{
|
2016-08-29 15:43:22 +02:00
|
|
|
$strDefault = '[INSTALL-PATH]/' . BACKREST_EXE;
|
2015-10-28 11:10:36 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-11-02 14:14:13 +02:00
|
|
|
if (docConfigOptionTypeTest($strOption, CFGDEF_TYPE_BOOLEAN))
|
2015-10-28 11:10:36 +02:00
|
|
|
{
|
2017-11-02 14:14:13 +02:00
|
|
|
$strDefault = docConfigOptionDefault($strOption, $strCommand) ? 'y' : 'n';
|
2015-10-28 11:10:36 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-11-02 14:14:13 +02:00
|
|
|
$strDefault = docConfigOptionDefault($strOption, $strCommand);
|
2015-10-28 11:10:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$strCodeBlock = "default: ${strDefault}";
|
|
|
|
}
|
|
|
|
# This won't work correctly until there is some notion of dependency
|
|
|
|
# elsif (optionRequired($strOption, $strCommand))
|
|
|
|
# {
|
|
|
|
# $strCodeBlock = 'required: y';
|
|
|
|
# }
|
|
|
|
|
|
|
|
# Get the allowed range if it exists
|
2017-11-02 14:14:13 +02:00
|
|
|
my ($strRangeMin, $strRangeMax) = docConfigOptionRange($strOption, $strCommand);
|
2015-10-28 11:10:36 +02:00
|
|
|
|
|
|
|
if (defined($strRangeMin))
|
|
|
|
{
|
|
|
|
$strCodeBlock .= (defined($strCodeBlock) ? "\n" : '') . "allowed: ${strRangeMin}-${strRangeMax}";
|
|
|
|
}
|
|
|
|
|
|
|
|
# Get the example
|
|
|
|
my $strExample;
|
|
|
|
|
2018-03-06 21:20:12 +02:00
|
|
|
my $strOptionPrefix = $rhConfigDefine->{$strOption}{&CFGDEF_PREFIX};
|
|
|
|
my $strOptionIndex = defined($strOptionPrefix) ?
|
|
|
|
"${strOptionPrefix}1-" . substr($strOption, length($strOptionPrefix) + 1) : $strOption;
|
|
|
|
|
2015-10-28 11:10:36 +02:00
|
|
|
if (defined($strCommand))
|
|
|
|
{
|
2017-11-02 14:14:13 +02:00
|
|
|
if (docConfigOptionTypeTest($strOption, CFGDEF_TYPE_BOOLEAN))
|
2015-10-28 11:10:36 +02:00
|
|
|
{
|
|
|
|
if ($$oOptionHash{&CONFIG_HELP_EXAMPLE} ne 'n' && $$oOptionHash{&CONFIG_HELP_EXAMPLE} ne 'y')
|
|
|
|
{
|
|
|
|
confess &log(ERROR, "option ${strOption} example should be boolean but value is: " .
|
|
|
|
$$oOptionHash{&CONFIG_HELP_EXAMPLE});
|
|
|
|
}
|
|
|
|
|
2018-03-06 21:20:12 +02:00
|
|
|
$strExample = '--' . ($$oOptionHash{&CONFIG_HELP_EXAMPLE} eq 'n' ? 'no-' : '') . $strOptionIndex;
|
2015-10-28 11:10:36 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-03-06 21:20:12 +02:00
|
|
|
$strExample = "--${strOptionIndex}=" . $$oOptionHash{&CONFIG_HELP_EXAMPLE};
|
2015-10-28 11:10:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-03-06 21:20:12 +02:00
|
|
|
$strExample = "${strOptionIndex}=" . $$oOptionHash{&CONFIG_HELP_EXAMPLE};
|
2015-10-28 11:10:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$strCodeBlock .= (defined($strCodeBlock) ? "\n" : '') . "example: ${strExample}";
|
|
|
|
|
|
|
|
$oOptionElement->
|
|
|
|
nodeAdd('code-block')->valueSet($strCodeBlock);
|
2018-02-04 01:27:38 +02:00
|
|
|
|
|
|
|
# Output deprecated names
|
|
|
|
if (defined($oOptionHash->{&CONFIG_HELP_NAME_ALT}))
|
|
|
|
{
|
|
|
|
my $strCaption = 'Deprecated Name' . (@{$oOptionHash->{&CONFIG_HELP_NAME_ALT}} > 1 ? 's' : '');
|
|
|
|
|
|
|
|
$oOptionElement->
|
|
|
|
nodeAdd('p')->textSet("${strCaption}: " . join(', ', @{$oOptionHash->{&CONFIG_HELP_NAME_ALT}}));
|
|
|
|
}
|
2015-10-28 11:10:36 +02:00
|
|
|
}
|
|
|
|
|
2015-09-08 13:31:24 +02:00
|
|
|
1;
|