Skip to content
Permalink
Browse files

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.
  • Loading branch information...
dwsteele committed May 13, 2019
1 parent 2d2bec8 commit 15a33bf74be84bda822e96c91e37479419b451a9
Showing with 12 additions and 19 deletions.
  1. +6 −0 doc/lib/BackRestDoc/Common/DocConfig.pm
  2. +4 −0 doc/xml/release.xml
  3. +2 −19 src/command/help/help.c
@@ -337,6 +337,12 @@ sub process

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;
}
}
@@ -163,6 +163,10 @@
<p>Improve coverage in <file>perl/exec</file> module.</p>
</release-item>

<release-item>
<p>Error on multiple option alternate names and simplify help command.</p>
</release-item>

<release-item>
<p>Use <code>THROW_ON_SYS_ERROR*()</code> to improve code coverage.</p>
</release-item>
@@ -356,26 +356,9 @@ helpRender(void)
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))
{
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");
}
strCatFmt(result, "\ndeprecated name: %s\n", cfgDefOptionHelpNameAltValue(optionDefId, 0));
}
}

0 comments on commit 15a33bf

Please sign in to comment.
You can’t perform that action at this time.