pldmtool: Create supported PDR types list dynamically
In current implementation the supported types list, used in the pldmtool
usage text, is hard-coded.
This patch uses the strToPDRType map to generate the list of supported
PDR types.
Tested.
Before:
'''
$ pldmtool platform GetPDR --help
....
-t,--type TEXT retrieve all PDRs of the requested type
supported types:
[terminusLocator, stateSensor, numericEffecter, stateEffecter, compactNumericSensor, sensorauxname, effecterAuxName, numericsensor, EntityAssociation, fruRecord, ... ]
....
'''
After:
'''
$ pldmtool platform GetPDR --help
....
-t,--type TEXT retrieve all PDRs of the requested type
supported types:
[compactnumericsensor, effecterauxname, entityassociation, frurecord, numericeffecter, numericsensor, sensorauxname, stateeffecter, statesensor, terminuslocator, ...]
....
'''
Change-Id: I2203848927445eaec3f861791f51c4ef31457beb
Signed-off-by: Aditya Kurdunkar <akurdunkar@nvidia.com>
diff --git a/pldmtool/pldm_platform_cmd.cpp b/pldmtool/pldm_platform_cmd.cpp
index 2b3685e..da147ba 100644
--- a/pldmtool/pldm_platform_cmd.cpp
+++ b/pldmtool/pldm_platform_cmd.cpp
@@ -158,15 +158,18 @@
"eg: The recordHandle value for the PDR to be retrieved and 0 "
"means get first PDR in the repository.");
pdrRecType = "";
- pdrOptionGroup->add_option(
- "-t, --type", pdrRecType,
- "retrieve all PDRs of the requested type\n"
- "supported types:\n"
- "[terminusLocator, stateSensor, "
- "numericEffecter, stateEffecter, "
- "compactNumericSensor, sensorauxname, "
- "effecterAuxName, numericsensor, "
- "EntityAssociation, fruRecord, ... ]");
+ std::string supportedPDRTypes = "";
+
+ for (const auto& [type, _] : strToPdrType)
+ {
+ supportedPDRTypes += (type + ", ");
+ }
+ supportedPDRTypes = std::format("[{}...]", supportedPDRTypes);
+
+ pdrOptionGroup->add_option("-t, --type", pdrRecType,
+ "retrieve all PDRs of the requested type\n"
+ "supported types:\n" +
+ supportedPDRTypes);
getPDRGroupOption = pdrOptionGroup->add_option(
"-i, --terminusID", pdrTerminus,