1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-07-03 00:26:59 +02:00

Error on multiple option alternate names and simplify help command.

There are currently no options with multiple alternate (deprecated) names so the code to render them in the help command could not be covered.

Remove the uncovered code and add an error when multiple alternate names are configured.  It's not clear that the current code was handling this correctly, so it will need to be reviewed if it comes up again.
This commit is contained in:
David Steele
2019-05-13 17:10:41 -04:00
parent 2d2bec842a
commit 15a33bf74b
3 changed files with 12 additions and 19 deletions

View File

@ -337,6 +337,12 @@ sub process
if (@stryNameAlt > 0) if (@stryNameAlt > 0)
{ {
if (@stryNameAlt != 1)
{
confess &log(
ERROR, "multiple alt names are not supported for option '${strOption}': " . join(', ', @stryNameAlt));
}
$oCommandOption->{&CONFIG_HELP_NAME_ALT} = \@stryNameAlt; $oCommandOption->{&CONFIG_HELP_NAME_ALT} = \@stryNameAlt;
} }
} }

View File

@ -163,6 +163,10 @@
<p>Improve coverage in <file>perl/exec</file> module.</p> <p>Improve coverage in <file>perl/exec</file> module.</p>
</release-item> </release-item>
<release-item>
<p>Error on multiple option alternate names and simplify help command.</p>
</release-item>
<release-item> <release-item>
<p>Use <code>THROW_ON_SYS_ERROR*()</code> to improve code coverage.</p> <p>Use <code>THROW_ON_SYS_ERROR*()</code> to improve code coverage.</p>
</release-item> </release-item>

View File

@ -356,26 +356,9 @@ helpRender(void)
strCatFmt(result, "default: %s\n", strPtr(defaultValue)); strCatFmt(result, "default: %s\n", strPtr(defaultValue));
} }
// Output alternate names (call them deprecated so the user will know not to use them) // Output alternate name (call it deprecated so the user will know not to use it)
if (cfgDefOptionHelpNameAlt(optionDefId)) if (cfgDefOptionHelpNameAlt(optionDefId))
{ strCatFmt(result, "\ndeprecated name: %s\n", cfgDefOptionHelpNameAltValue(optionDefId, 0));
strCat(result, "\ndeprecated name");
if (cfgDefOptionHelpNameAltValueTotal(optionDefId) > 1) // {uncovered_branch - no option with more than one}
strCat(result, "s"); // {+uncovered}
strCat(result, ": ");
for (unsigned int nameAltIdx = 0; nameAltIdx < cfgDefOptionHelpNameAltValueTotal(optionDefId); nameAltIdx++)
{
if (nameAltIdx != 0) // {uncovered_branch - no option with more than one}
strCat(result, ", "); // {+uncovered}
strCat(result, cfgDefOptionHelpNameAltValue(optionDefId, nameAltIdx));
}
strCat(result, "\n");
}
} }
} }