1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2026-05-22 10:15:16 +02:00

Fix help not displaying help for the help command.

'pgbackrest help help' just displayed the help overview, rather than display help for the help command.

Fix this by making sure the command is set and routing correctly in the help command.
This commit is contained in:
David Steele
2024-01-22 12:33:40 -03:00
parent 68db3075d7
commit 0aaa0772f5
4 changed files with 28 additions and 4 deletions
+1 -1
View File
@@ -289,7 +289,7 @@ helpRender(const Buffer *const helpData)
const String *more = NULL;
// Display general help
if (cfgCommand() == cfgCmdHelp || cfgCommand() == cfgCmdNone)
if (cfgCommand() == cfgCmdNone)
{
strCatZ(
result,
+4 -1
View File
@@ -1766,8 +1766,11 @@ cfgParse(const Storage *const storage, const unsigned int argListSize, const cha
if (!(parseRuleCommand[config->command].commandRoleValid & ((unsigned int)1 << config->commandRole)))
THROW_FMT(CommandInvalidError, "invalid command/role combination '%s'", arg);
if (config->command == cfgCmdHelp)
if (config->command == cfgCmdHelp && !config->help)
{
config->command = cfgCmdNone;
config->help = true;
}
else
commandSet = true;
}
+11
View File
@@ -886,6 +886,17 @@ testRun(void)
TEST_RESULT_VOID(cfgLoad(strLstSize(argList), strLstPtr(argList)), "help command for backup");
TEST_RESULT_UINT(ioBufferSize(), 1048576, "buffer size set to option default");
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("help command for help");
argList = strLstNew();
strLstAddZ(argList, PROJECT_BIN);
strLstAddZ(argList, "help");
strLstAddZ(argList, "help");
TEST_RESULT_VOID(cfgLoad(strLstSize(argList), strLstPtr(argList)), "load config");
TEST_RESULT_UINT(ioBufferSize(), 1048576, "buffer size set to option default");
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("command takes lock and opens log file and uses custom tcp settings");
+12 -2
View File
@@ -1529,8 +1529,7 @@ testRun(void)
TEST_RESULT_VOID(cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), "help command");
TEST_RESULT_BOOL(cfgCommandHelp(), true, "help is set");
TEST_RESULT_INT(cfgCommand(), cfgCmdHelp, "command is help");
TEST_RESULT_Z(cfgCommandName(), "help", "command name is help");
TEST_RESULT_INT(cfgCommand(), cfgCmdNone, "command is help");
argList = strLstNew();
strLstAddZ(argList, TEST_BACKREST_EXE);
@@ -1541,6 +1540,17 @@ testRun(void)
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), "help for version command");
TEST_RESULT_BOOL(cfgCommandHelp(), true, "help is set");
TEST_RESULT_INT(cfgCommand(), cfgCmdVersion, "command is version");
TEST_RESULT_Z(cfgCommandName(), "version", "command name is version");
argList = strLstNew();
strLstAddZ(argList, TEST_BACKREST_EXE);
strLstAddZ(argList, "help");
strLstAddZ(argList, "help");
TEST_RESULT_VOID(
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), "load config");
TEST_RESULT_BOOL(cfgCommandHelp(), true, "help is set");
TEST_RESULT_INT(cfgCommand(), cfgCmdHelp, "command is help");
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("help option");