1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-09-16 09:06:18 +02:00

Remove configurable option hints.

db-path was the only option with a hint so the feature seemed wasteful. All missing stanza options now output the same hint without needing configuration.
This commit is contained in:
David Steele
2017-10-30 10:58:04 -04:00
parent 1ef27ec8c2
commit 55f68ef013
10 changed files with 6 additions and 60 deletions

View File

@@ -72,7 +72,6 @@ use constant BLDLCL_FUNCTION_DEPEND_OPTION => BLDLCL_FU
use constant BLDLCL_FUNCTION_DEPEND_VALUE => BLDLCL_FUNCTION_DEPEND . 'Value';
use constant BLDLCL_FUNCTION_DEPEND_VALUE_TOTAL => BLDLCL_FUNCTION_DEPEND_VALUE . 'Total';
use constant BLDLCL_FUNCTION_HINT => BLDLCL_PREFIX_RULE_OPTION . 'Hint';
use constant BLDLCL_FUNCTION_NAME_ALT => BLDLCL_PREFIX_RULE_OPTION . 'NameAlt';
use constant BLDLCL_FUNCTION_NEGATE => BLDLCL_PREFIX_RULE_OPTION . 'Negate';
use constant BLDLCL_FUNCTION_PREFIX => BLDLCL_PREFIX_RULE_OPTION . 'Prefix';
@@ -357,16 +356,6 @@ my $rhBuild =
&BLD_FUNCTION_DEPEND_RESULT => true,
},
&BLDLCL_FUNCTION_HINT =>
{
&BLD_SUMMARY => 'some clue as to what value the user should provide when the option is missing but required',
&BLD_RETURN_TYPE => CGEN_DATATYPE_CONSTCHAR,
&BLD_PARAM => [BLDLCL_PARAM_COMMANDID, BLDLCL_PARAM_OPTIONID],
&BLD_TRUTH_DEFAULT => undef,
&BLD_FUNCTION_DEPEND => BLDLCL_FUNCTION_VALID,
&BLD_FUNCTION_DEPEND_RESULT => true,
},
&BLDLCL_FUNCTION_OPTION_ID =>
{
&BLD_SUMMARY => 'lookup option id using option name',
@@ -541,7 +530,6 @@ sub buildConfig
if (cfgRuleOptionValid($strCommand, $strOption))
{
functionMatrix(BLDLCL_FUNCTION_DEFAULT, [$iCommandId, $iOptionId], cfgRuleOptionDefault($strCommand, $strOption));
functionMatrix(BLDLCL_FUNCTION_HINT, [$iCommandId, $iOptionId], cfgRuleOptionHint($strCommand, $strOption));
functionMatrix(BLDLCL_FUNCTION_REQUIRED, [$iCommandId, $iOptionId], cfgRuleOptionRequired($strCommand, $strOption));
# Option dependencies

View File

@@ -16,6 +16,10 @@
<release-item>
<p>Add <id>list</id> type for options. The <id>hash</id> type was being used for lists with an additional flag (`value-hash`) to indicate that it was not really a hash.</p>
</release-item>
<release-item>
<p>Remove configurable option hints. <br-option>db-path</br-option> was the only option with a hint so the feature seemed wasteful. All missing stanza options now output the same hint without needing configuration.</p>
</release-item>
</release-refactor-list>
</release-core-list>

View File

@@ -775,8 +775,8 @@ sub optionValidate
{
confess &log(ERROR,
"${strCommand} command requires option: ${strOption}" .
(defined(cfgRuleOptionHint($iCommandId, $iOptionId)) ?
"\nHINT: " . cfgRuleOptionHint($iCommandId, $iOptionId) : ''),
(defined(cfgRuleOptionSection($iOptionId)) &&
cfgRuleOptionSection($iOptionId) eq CFGDEF_SECTION_STANZA ? "\nHINT: does this stanza exist?" : ''),
ERROR_OPTION_REQUIRED);
}
}

View File

@@ -409,8 +409,6 @@ use constant CFGBLDDEF_RULE_DEPEND_OPTION => 'depend-o
push @EXPORT, qw(CFGBLDDEF_RULE_DEPEND_OPTION);
use constant CFGBLDDEF_RULE_DEPEND_LIST => 'depend-list';
push @EXPORT, qw(CFGBLDDEF_RULE_DEPEND_LIST);
use constant CFGBLDDEF_RULE_HINT => 'hint';
push @EXPORT, qw(CFGBLDDEF_RULE_HINT);
use constant CFGBLDDEF_RULE_INDEX => 'index';
push @EXPORT, qw(CFGBLDDEF_RULE_INDEX);
use constant CFGBLDDEF_RULE_NEGATE => 'negate';
@@ -1694,7 +1692,6 @@ my %hOptionRule =
&CFGBLDDEF_RULE_TYPE => CFGOPTDEF_TYPE_STRING,
&CFGBLDDEF_RULE_PREFIX => CFGDEF_PREFIX_DB,
&CFGBLDDEF_RULE_REQUIRED => true,
&CFGBLDDEF_RULE_HINT => "does this stanza exist?",
&CFGBLDDEF_RULE_COMMAND =>
{
&CFGCMD_ARCHIVE_GET =>

View File

@@ -387,19 +387,6 @@ sub cfgRuleOptionDependValueValid
push @EXPORT, qw(cfgRuleOptionDependValueValid);
####################################################################################################################################
# cfgRuleOptionHint - option hint, if any
####################################################################################################################################
sub cfgRuleOptionHint
{
my $strCommand = shift;
my $strOption = cfgOptionName(shift);
return cfgOptionRule($strCommand, $strOption, CFGBLDDEF_RULE_HINT);
}
push @EXPORT, qw(cfgRuleOptionHint);
####################################################################################################################################
# cfgOptionIndexTotal - max index for options that are indexed (e.g., db)
####################################################################################################################################

View File

@@ -77,7 +77,6 @@ my $rhExport =
cfgRuleOptionDependValue
cfgRuleOptionDependValueTotal
cfgRuleOptionDependValueValid
cfgRuleOptionHint
cfgRuleOptionNameAlt
cfgRuleOptionNegate
cfgRuleOptionPrefix

View File

@@ -81,11 +81,6 @@ cfgRuleOptionDependValueValid(commandId, optionId, value)
U32 optionId
const char *value
const char *
cfgRuleOptionHint(commandId, optionId)
U32 commandId
U32 optionId
const char *
cfgRuleOptionNameAlt(optionId)
U32 optionId

View File

@@ -494,25 +494,6 @@ This function is valid when `cfgRuleOptionDepend()` = `true`.
| cfgRuleOptionDependValueTotal | _\<ANY\>_ | `CFGOPT_TEST_DELAY` | `1` |
| cfgRuleOptionDependValueTotal | _\<ANY\>_ | `CFGOPT_TEST_POINT` | `1` |
## cfgRuleOptionHint
Some clue as to what value the user should provide when the option is missing but required.
### Truth Table:
This function is valid when `cfgRuleOptionValid()` = `true`. Permutations that return `NULL` are excluded for brevity.
| Function | commandId | optionId | Result |
| -------- | --------- | -------- | ------ |
| cfgRuleOptionHint | _\<ANY\>_ | `CFGOPT_DB1_PATH` | `"does this stanza exist?"` |
| cfgRuleOptionHint | _\<ANY\>_ | `CFGOPT_DB2_PATH` | `"does this stanza exist?"` |
| cfgRuleOptionHint | _\<ANY\>_ | `CFGOPT_DB3_PATH` | `"does this stanza exist?"` |
| cfgRuleOptionHint | _\<ANY\>_ | `CFGOPT_DB4_PATH` | `"does this stanza exist?"` |
| cfgRuleOptionHint | _\<ANY\>_ | `CFGOPT_DB5_PATH` | `"does this stanza exist?"` |
| cfgRuleOptionHint | _\<ANY\>_ | `CFGOPT_DB6_PATH` | `"does this stanza exist?"` |
| cfgRuleOptionHint | _\<ANY\>_ | `CFGOPT_DB7_PATH` | `"does this stanza exist?"` |
| cfgRuleOptionHint | _\<ANY\>_ | `CFGOPT_DB8_PATH` | `"does this stanza exist?"` |
## cfgRuleOptionNameAlt
Alternate name for the option primarily used for deprecated names.

View File

@@ -29,7 +29,6 @@ bool cfgRuleOptionDepend(int commandId, int optionId);
int cfgRuleOptionDependOption(int commandId, int optionId);
const char *cfgRuleOptionDependValue(int commandId, int optionId, int valueId);
int cfgRuleOptionDependValueTotal(int commandId, int optionId);
const char *cfgRuleOptionHint(int commandId, int optionId);
const char *cfgRuleOptionNameAlt(int optionId);
bool cfgRuleOptionNegate(int optionId);
const char *cfgRuleOptionPrefix(int optionId);

View File

@@ -73,8 +73,6 @@ void testRun()
cfgRuleOptionDependValueValid(commandId, optionId, BOGUS_STR), NULL, "bogus depend option value");
}
cfgRuleOptionHint(commandId, optionId);
cfgRuleOptionRequired(commandId, optionId);
}
}
@@ -129,8 +127,6 @@ void testRun()
TEST_RESULT_BOOL(
cfgRuleOptionDependValueValid(CFGCMD_RESTORE, CFGOPT_TARGET, BOGUS_STR), false, "depend option value not valid");
TEST_RESULT_STR(cfgRuleOptionHint(CFGCMD_BACKUP, CFGOPT_DB1_PATH), "does this stanza exist?", "hint exists");
TEST_RESULT_INT(cfgOptionIndexTotal(CFGOPT_DB_PATH), 8, "index total > 1");
TEST_RESULT_INT(cfgOptionIndexTotal(CFGOPT_REPO_PATH), 1, "index total == 1");