1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-11-08 03:22:25 +03:00

Fix rendering of key/value and list options in help.

Reported by Clinton Adams.
This commit is contained in:
David Steele
2018-05-01 14:07:08 -04:00
parent 1a1ed8d6b9
commit fd1984239e
3 changed files with 46 additions and 0 deletions

View File

@@ -2,6 +2,7 @@
Help Command
***********************************************************************************************************************************/
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include "common/io/handle.h"
@@ -73,6 +74,37 @@ helpRenderValue(const Variant *value)
else
result = strNew("n");
}
else if (varType(value) == varTypeKeyValue)
{
result = strNew("");
const KeyValue *optionKv = varKv(value);
const VariantList *keyList = kvKeyList(optionKv);
for (uint keyIdx = 0; keyIdx < varLstSize(keyList); keyIdx++)
{
if (keyIdx != 0)
strCat(result, ", ");
strCatFmt(
result, "%s=%s", strPtr(varStr(varLstGet(keyList, keyIdx))),
strPtr(varStrForce(kvGet(optionKv, varLstGet(keyList, keyIdx)))));
}
}
else if (varType(value) == varTypeVariantList)
{
result = strNew("");
const VariantList *list = varVarLst(value);
for (uint listIdx = 0; listIdx < varLstSize(list); listIdx++)
{
if (listIdx != 0)
strCat(result, ", ");
strCatFmt(result, "%s", strPtr(varStr(varLstGet(list, listIdx))));
}
}
else
result = varStrForce(value);
}