xref: /openbmc/openpower-vpd-parser/vpd-tool/src/vpd_tool_main.cpp (revision fa5e4d325ef9cea3c841fe89d202c340f92bd8c6)
1*fa5e4d32SSunny Srivastava #include "tool_constants.hpp"
2*fa5e4d32SSunny Srivastava #include "vpd_tool.hpp"
3*fa5e4d32SSunny Srivastava 
4*fa5e4d32SSunny Srivastava #include <CLI/CLI.hpp>
5*fa5e4d32SSunny Srivastava 
6*fa5e4d32SSunny Srivastava #include <filesystem>
7*fa5e4d32SSunny Srivastava #include <iostream>
8*fa5e4d32SSunny Srivastava 
9*fa5e4d32SSunny Srivastava /**
10*fa5e4d32SSunny Srivastava  * @brief API to perform manufacturing clean.
11*fa5e4d32SSunny Srivastava  *
12*fa5e4d32SSunny Srivastava  * @param[in] i_mfgCleanConfirmFlag - Confirmation flag to perform manufacturing
13*fa5e4d32SSunny Srivastava  * clean.
14*fa5e4d32SSunny Srivastava  *
15*fa5e4d32SSunny Srivastava  * @return Status returned by cleanSystemVpd operation, success otherwise.
16*fa5e4d32SSunny Srivastava  */
doMfgClean(const auto & i_mfgCleanConfirmFlag)17*fa5e4d32SSunny Srivastava int doMfgClean(const auto& i_mfgCleanConfirmFlag)
18*fa5e4d32SSunny Srivastava {
19*fa5e4d32SSunny Srivastava     if (i_mfgCleanConfirmFlag->empty())
20*fa5e4d32SSunny Srivastava     {
21*fa5e4d32SSunny Srivastava         constexpr auto MAX_CONFIRMATION_STR_LENGTH{3};
22*fa5e4d32SSunny Srivastava         std::string l_confirmation{};
23*fa5e4d32SSunny Srivastava         std::cout
24*fa5e4d32SSunny Srivastava             << "This option resets some of the system VPD keywords to their default values. Do you really wish to proceed further?[yes/no]:";
25*fa5e4d32SSunny Srivastava         std::cin >> std::setw(MAX_CONFIRMATION_STR_LENGTH) >> l_confirmation;
26*fa5e4d32SSunny Srivastava 
27*fa5e4d32SSunny Srivastava         if (l_confirmation != "yes")
28*fa5e4d32SSunny Srivastava         {
29*fa5e4d32SSunny Srivastava             return vpd::constants::SUCCESS;
30*fa5e4d32SSunny Srivastava         }
31*fa5e4d32SSunny Srivastava     }
32*fa5e4d32SSunny Srivastava 
33*fa5e4d32SSunny Srivastava     vpd::VpdTool l_vpdToolObj;
34*fa5e4d32SSunny Srivastava     return l_vpdToolObj.cleanSystemVpd();
35*fa5e4d32SSunny Srivastava }
36*fa5e4d32SSunny Srivastava 
37*fa5e4d32SSunny Srivastava /**
38*fa5e4d32SSunny Srivastava  * @brief API to write keyword's value.
39*fa5e4d32SSunny Srivastava  *
40*fa5e4d32SSunny Srivastava  * @param[in] i_hardwareFlag - Flag to perform write on hardware.
41*fa5e4d32SSunny Srivastava  * @param[in] i_keywordValueOption - Option to read keyword value from command.
42*fa5e4d32SSunny Srivastava  * @param[in] i_vpdPath - DBus object path or EEPROM path.
43*fa5e4d32SSunny Srivastava  * @param[in] i_recordName - Record to be updated.
44*fa5e4d32SSunny Srivastava  * @param[in] i_keywordName - Keyword to be updated.
45*fa5e4d32SSunny Srivastava  * @param[in] i_keywordValue - Value to be updated in keyword.
46*fa5e4d32SSunny Srivastava  *
47*fa5e4d32SSunny Srivastava  * @return Status of writeKeyword operation, failure otherwise.
48*fa5e4d32SSunny Srivastava  */
writeKeyword(const auto & i_hardwareFlag,const auto & i_keywordValueOption,const std::string & i_vpdPath,const std::string & i_recordName,const std::string & i_keywordName,const std::string & i_keywordValue)49*fa5e4d32SSunny Srivastava int writeKeyword(const auto& i_hardwareFlag, const auto& i_keywordValueOption,
50*fa5e4d32SSunny Srivastava                  const std::string& i_vpdPath, const std::string& i_recordName,
51*fa5e4d32SSunny Srivastava                  const std::string& i_keywordName,
52*fa5e4d32SSunny Srivastava                  const std::string& i_keywordValue)
53*fa5e4d32SSunny Srivastava {
54*fa5e4d32SSunny Srivastava     std::error_code l_ec;
55*fa5e4d32SSunny Srivastava 
56*fa5e4d32SSunny Srivastava     if (!i_hardwareFlag->empty() && !std::filesystem::exists(i_vpdPath, l_ec))
57*fa5e4d32SSunny Srivastava     {
58*fa5e4d32SSunny Srivastava         std::cerr << "Given EEPROM file path doesn't exist : " + i_vpdPath
59*fa5e4d32SSunny Srivastava                   << std::endl;
60*fa5e4d32SSunny Srivastava         return vpd::constants::FAILURE;
61*fa5e4d32SSunny Srivastava     }
62*fa5e4d32SSunny Srivastava 
63*fa5e4d32SSunny Srivastava     if (l_ec)
64*fa5e4d32SSunny Srivastava     {
65*fa5e4d32SSunny Srivastava         std::cerr << "filesystem call exists failed for file: " << i_vpdPath
66*fa5e4d32SSunny Srivastava                   << ", reason: " + l_ec.message() << std::endl;
67*fa5e4d32SSunny Srivastava         return vpd::constants::FAILURE;
68*fa5e4d32SSunny Srivastava     }
69*fa5e4d32SSunny Srivastava 
70*fa5e4d32SSunny Srivastava     if (!i_keywordValueOption->empty() && i_keywordValue.empty())
71*fa5e4d32SSunny Srivastava     {
72*fa5e4d32SSunny Srivastava         std::cerr
73*fa5e4d32SSunny Srivastava             << "Please provide keyword value.\nUse --value/--file to give "
74*fa5e4d32SSunny Srivastava                "keyword value. Refer --help."
75*fa5e4d32SSunny Srivastava             << std::endl;
76*fa5e4d32SSunny Srivastava         return vpd::constants::FAILURE;
77*fa5e4d32SSunny Srivastava     }
78*fa5e4d32SSunny Srivastava 
79*fa5e4d32SSunny Srivastava     if (i_keywordValueOption->empty())
80*fa5e4d32SSunny Srivastava     {
81*fa5e4d32SSunny Srivastava         std::cerr
82*fa5e4d32SSunny Srivastava             << "Please provide keyword value.\nUse --value/--file to give "
83*fa5e4d32SSunny Srivastava                "keyword value. Refer --help."
84*fa5e4d32SSunny Srivastava             << std::endl;
85*fa5e4d32SSunny Srivastava         return vpd::constants::FAILURE;
86*fa5e4d32SSunny Srivastava     }
87*fa5e4d32SSunny Srivastava 
88*fa5e4d32SSunny Srivastava     vpd::VpdTool l_vpdToolObj;
89*fa5e4d32SSunny Srivastava     return l_vpdToolObj.writeKeyword(i_vpdPath, i_recordName, i_keywordName,
90*fa5e4d32SSunny Srivastava                                      i_keywordValue, !i_hardwareFlag->empty());
91*fa5e4d32SSunny Srivastava }
92*fa5e4d32SSunny Srivastava 
93*fa5e4d32SSunny Srivastava /**
94*fa5e4d32SSunny Srivastava  * @brief API to read keyword's value.
95*fa5e4d32SSunny Srivastava  *
96*fa5e4d32SSunny Srivastava  * @param[in] i_hardwareFlag - Flag to perform write on hardware.
97*fa5e4d32SSunny Srivastava  * @param[in] i_vpdPath - DBus object path or EEPROM path.
98*fa5e4d32SSunny Srivastava  * @param[in] i_recordName - Record to be updated.
99*fa5e4d32SSunny Srivastava  * @param[in] i_keywordName - Keyword to be updated.
100*fa5e4d32SSunny Srivastava  * @param[in] i_filePath - File path to save keyword's read value.
101*fa5e4d32SSunny Srivastava  *
102*fa5e4d32SSunny Srivastava  * @return Status of readKeyword operation, failure otherwise.
103*fa5e4d32SSunny Srivastava  */
readKeyword(const auto & i_hardwareFlag,const std::string & i_vpdPath,const std::string & i_recordName,const std::string & i_keywordName,const std::string & i_filePath)104*fa5e4d32SSunny Srivastava int readKeyword(const auto& i_hardwareFlag, const std::string& i_vpdPath,
105*fa5e4d32SSunny Srivastava                 const std::string& i_recordName,
106*fa5e4d32SSunny Srivastava                 const std::string& i_keywordName, const std::string& i_filePath)
107*fa5e4d32SSunny Srivastava {
108*fa5e4d32SSunny Srivastava     std::error_code l_ec;
109*fa5e4d32SSunny Srivastava 
110*fa5e4d32SSunny Srivastava     if (!i_hardwareFlag->empty() && !std::filesystem::exists(i_vpdPath, l_ec))
111*fa5e4d32SSunny Srivastava     {
112*fa5e4d32SSunny Srivastava         std::string l_errMessage{
113*fa5e4d32SSunny Srivastava             "Given EEPROM file path doesn't exist : " + i_vpdPath};
114*fa5e4d32SSunny Srivastava 
115*fa5e4d32SSunny Srivastava         if (l_ec)
116*fa5e4d32SSunny Srivastava         {
117*fa5e4d32SSunny Srivastava             l_errMessage += ". filesystem call exists failed, reason: " +
118*fa5e4d32SSunny Srivastava                             l_ec.message();
119*fa5e4d32SSunny Srivastava         }
120*fa5e4d32SSunny Srivastava 
121*fa5e4d32SSunny Srivastava         std::cerr << l_errMessage << std::endl;
122*fa5e4d32SSunny Srivastava         return vpd::constants::FAILURE;
123*fa5e4d32SSunny Srivastava     }
124*fa5e4d32SSunny Srivastava 
125*fa5e4d32SSunny Srivastava     bool l_isHardwareOperation = (!i_hardwareFlag->empty() ? true : false);
126*fa5e4d32SSunny Srivastava 
127*fa5e4d32SSunny Srivastava     vpd::VpdTool l_vpdToolObj;
128*fa5e4d32SSunny Srivastava     return l_vpdToolObj.readKeyword(i_vpdPath, i_recordName, i_keywordName,
129*fa5e4d32SSunny Srivastava                                     l_isHardwareOperation, i_filePath);
130*fa5e4d32SSunny Srivastava }
131*fa5e4d32SSunny Srivastava 
132*fa5e4d32SSunny Srivastava /**
133*fa5e4d32SSunny Srivastava  * @brief API to check option value pair in the tool command.
134*fa5e4d32SSunny Srivastava  *
135*fa5e4d32SSunny Srivastava  * In VPD tool command, some of the option(s) mandate values to be passed along
136*fa5e4d32SSunny Srivastava  * with the option. This API based on option, detects those mandatory value(s).
137*fa5e4d32SSunny Srivastava  *
138*fa5e4d32SSunny Srivastava  * @param[in] i_objectOption - Option to pass object path.
139*fa5e4d32SSunny Srivastava  * @param[in] i_vpdPath - Object path, DBus or EEPROM.
140*fa5e4d32SSunny Srivastava  * @param[in] i_recordOption - Option to pass record name.
141*fa5e4d32SSunny Srivastava  * @param[in] i_recordName - Record name.
142*fa5e4d32SSunny Srivastava  * @param[in] i_keywordOption - Option to pass keyword name.
143*fa5e4d32SSunny Srivastava  * @param[in] i_keywordName - Keyword name.
144*fa5e4d32SSunny Srivastava  *
145*fa5e4d32SSunny Srivastava  * @return Success if corresponding value is found against option, failure
146*fa5e4d32SSunny Srivastava  * otherwise.
147*fa5e4d32SSunny Srivastava  */
checkOptionValuePair(const auto & i_objectOption,const auto & i_vpdPath,const auto & i_recordOption,const auto & i_recordName,const auto & i_keywordOption,const auto & i_keywordName)148*fa5e4d32SSunny Srivastava int checkOptionValuePair(const auto& i_objectOption, const auto& i_vpdPath,
149*fa5e4d32SSunny Srivastava                          const auto& i_recordOption, const auto& i_recordName,
150*fa5e4d32SSunny Srivastava                          const auto& i_keywordOption, const auto& i_keywordName)
151*fa5e4d32SSunny Srivastava {
152*fa5e4d32SSunny Srivastava     if (!i_objectOption->empty() && i_vpdPath.empty())
153*fa5e4d32SSunny Srivastava     {
154*fa5e4d32SSunny Srivastava         std::cout << "Given path is empty." << std::endl;
155*fa5e4d32SSunny Srivastava         return vpd::constants::FAILURE;
156*fa5e4d32SSunny Srivastava     }
157*fa5e4d32SSunny Srivastava 
158*fa5e4d32SSunny Srivastava     if (!i_recordOption->empty() &&
159*fa5e4d32SSunny Srivastava         (i_recordName.size() != vpd::constants::RECORD_SIZE))
160*fa5e4d32SSunny Srivastava     {
161*fa5e4d32SSunny Srivastava         std::cerr << "Record " << i_recordName << " is not supported."
162*fa5e4d32SSunny Srivastava                   << std::endl;
163*fa5e4d32SSunny Srivastava         return vpd::constants::FAILURE;
164*fa5e4d32SSunny Srivastava     }
165*fa5e4d32SSunny Srivastava 
166*fa5e4d32SSunny Srivastava     if (!i_keywordOption->empty() &&
167*fa5e4d32SSunny Srivastava         (i_keywordName.size() != vpd::constants::KEYWORD_SIZE))
168*fa5e4d32SSunny Srivastava     {
169*fa5e4d32SSunny Srivastava         std::cerr << "Keyword " << i_keywordName << " is not supported."
170*fa5e4d32SSunny Srivastava                   << std::endl;
171*fa5e4d32SSunny Srivastava         return vpd::constants::FAILURE;
172*fa5e4d32SSunny Srivastava     }
173*fa5e4d32SSunny Srivastava 
174*fa5e4d32SSunny Srivastava     return vpd::constants::SUCCESS;
175*fa5e4d32SSunny Srivastava }
176*fa5e4d32SSunny Srivastava 
177*fa5e4d32SSunny Srivastava /**
178*fa5e4d32SSunny Srivastava  * @brief API to create app footer.
179*fa5e4d32SSunny Srivastava  *
180*fa5e4d32SSunny Srivastava  * @param[in] i_app - CLI::App object.
181*fa5e4d32SSunny Srivastava  */
updateFooter(CLI::App & i_app)182*fa5e4d32SSunny Srivastava void updateFooter(CLI::App& i_app)
183*fa5e4d32SSunny Srivastava {
184*fa5e4d32SSunny Srivastava     i_app.footer(
185*fa5e4d32SSunny Srivastava         "Read:\n"
186*fa5e4d32SSunny Srivastava         "    IPZ Format:\n"
187*fa5e4d32SSunny Srivastava         "        From DBus to console: "
188*fa5e4d32SSunny Srivastava         "vpd-tool -r -O <DBus Object Path> -R <Record Name> -K <Keyword Name>\n"
189*fa5e4d32SSunny Srivastava         "        From DBus to file: "
190*fa5e4d32SSunny Srivastava         "vpd-tool -r -O <DBus Object Path> -R <Record Name> -K <Keyword Name> --file <File Path>\n"
191*fa5e4d32SSunny Srivastava         "        From hardware to console: "
192*fa5e4d32SSunny Srivastava         "vpd-tool -r -H -O <EEPROM Path> -R <Record Name> -K <Keyword Name>\n"
193*fa5e4d32SSunny Srivastava         "        From hardware to file: "
194*fa5e4d32SSunny Srivastava         "vpd-tool -r -H -O <EEPROM Path> -R <Record Name> -K <Keyword Name> --file <File Path>\n"
195*fa5e4d32SSunny Srivastava         "Write:\n"
196*fa5e4d32SSunny Srivastava         "    IPZ Format:\n"
197*fa5e4d32SSunny Srivastava         "        On DBus: "
198*fa5e4d32SSunny Srivastava         "vpd-tool -w/-u -O <DBus Object Path> -R <Record Name> -K <Keyword Name> -V <Keyword Value>\n"
199*fa5e4d32SSunny Srivastava         "        On DBus, take keyword value from file:\n"
200*fa5e4d32SSunny Srivastava         "              vpd-tool -w/-u -O <DBus Object Path> -R <Record Name> -K <Keyword Name> --file <File Path>\n"
201*fa5e4d32SSunny Srivastava         "        On hardware: "
202*fa5e4d32SSunny Srivastava         "vpd-tool -w/-u -H -O <EEPROM Path> -R <Record Name> -K <Keyword Name> -V <Keyword Value>\n"
203*fa5e4d32SSunny Srivastava         "        On hardware, take keyword value from file:\n"
204*fa5e4d32SSunny Srivastava         "              vpd-tool -w/-u -H -O <EEPROM Path> -R <Record Name> -K <Keyword Name> --file <File Path>\n"
205*fa5e4d32SSunny Srivastava         "Dump Object:\n"
206*fa5e4d32SSunny Srivastava         "    From DBus to console: "
207*fa5e4d32SSunny Srivastava         "vpd-tool -o -O <DBus Object Path>\n"
208*fa5e4d32SSunny Srivastava         "Fix System VPD:\n"
209*fa5e4d32SSunny Srivastava         "    vpd-tool --fixSystemVPD\n"
210*fa5e4d32SSunny Srivastava         "MfgClean:\n"
211*fa5e4d32SSunny Srivastava         "        Flag to clean and reset specific keywords on system VPD to its default value.\n"
212*fa5e4d32SSunny Srivastava         "        vpd-tool --mfgClean\n"
213*fa5e4d32SSunny Srivastava         "Dump Inventory:\n"
214*fa5e4d32SSunny Srivastava         "   From DBus to console in JSON format: "
215*fa5e4d32SSunny Srivastava         "vpd-tool -i\n"
216*fa5e4d32SSunny Srivastava         "   From DBus to console in Table format: "
217*fa5e4d32SSunny Srivastava         "vpd-tool -i -t\n");
218*fa5e4d32SSunny Srivastava }
219*fa5e4d32SSunny Srivastava 
main(int argc,char ** argv)220*fa5e4d32SSunny Srivastava int main(int argc, char** argv)
221*fa5e4d32SSunny Srivastava {
222*fa5e4d32SSunny Srivastava     CLI::App l_app{"VPD Command Line Tool"};
223*fa5e4d32SSunny Srivastava 
224*fa5e4d32SSunny Srivastava     std::string l_vpdPath{};
225*fa5e4d32SSunny Srivastava     std::string l_recordName{};
226*fa5e4d32SSunny Srivastava     std::string l_keywordName{};
227*fa5e4d32SSunny Srivastava     std::string l_filePath{};
228*fa5e4d32SSunny Srivastava     std::string l_keywordValue{};
229*fa5e4d32SSunny Srivastava 
230*fa5e4d32SSunny Srivastava     updateFooter(l_app);
231*fa5e4d32SSunny Srivastava 
232*fa5e4d32SSunny Srivastava     auto l_objectOption =
233*fa5e4d32SSunny Srivastava         l_app.add_option("--object, -O", l_vpdPath, "File path");
234*fa5e4d32SSunny Srivastava     auto l_recordOption =
235*fa5e4d32SSunny Srivastava         l_app.add_option("--record, -R", l_recordName, "Record name");
236*fa5e4d32SSunny Srivastava     auto l_keywordOption =
237*fa5e4d32SSunny Srivastava         l_app.add_option("--keyword, -K", l_keywordName, "Keyword name");
238*fa5e4d32SSunny Srivastava 
239*fa5e4d32SSunny Srivastava     // Enable when file option is implemented.
240*fa5e4d32SSunny Srivastava     /*auto l_fileOption = l_app.add_option("--file", l_filePath,
241*fa5e4d32SSunny Srivastava                                          "Absolute file path");*/
242*fa5e4d32SSunny Srivastava 
243*fa5e4d32SSunny Srivastava     auto l_keywordValueOption =
244*fa5e4d32SSunny Srivastava         l_app.add_option("--value, -V", l_keywordValue,
245*fa5e4d32SSunny Srivastava                          "Keyword value in ascii/hex format."
246*fa5e4d32SSunny Srivastava                          " ascii ex: 01234; hex ex: 0x30313233");
247*fa5e4d32SSunny Srivastava 
248*fa5e4d32SSunny Srivastava     auto l_hardwareFlag =
249*fa5e4d32SSunny Srivastava         l_app.add_flag("--Hardware, -H", "CAUTION: Developer only option.");
250*fa5e4d32SSunny Srivastava 
251*fa5e4d32SSunny Srivastava     auto l_readFlag = l_app.add_flag("--readKeyword, -r", "Read keyword")
252*fa5e4d32SSunny Srivastava                           ->needs(l_objectOption)
253*fa5e4d32SSunny Srivastava                           ->needs(l_recordOption)
254*fa5e4d32SSunny Srivastava                           ->needs(l_keywordOption);
255*fa5e4d32SSunny Srivastava 
256*fa5e4d32SSunny Srivastava     auto l_writeFlag =
257*fa5e4d32SSunny Srivastava         l_app
258*fa5e4d32SSunny Srivastava             .add_flag(
259*fa5e4d32SSunny Srivastava                 "--writeKeyword, -w,--updateKeyword, -u",
260*fa5e4d32SSunny Srivastava                 "Write keyword, Note: Irrespective of DBus or hardware path provided, primary and backup, redundant EEPROM(if any) paths will get updated with given key value")
261*fa5e4d32SSunny Srivastava             ->needs(l_objectOption)
262*fa5e4d32SSunny Srivastava             ->needs(l_recordOption)
263*fa5e4d32SSunny Srivastava             ->needs(l_keywordOption);
264*fa5e4d32SSunny Srivastava 
265*fa5e4d32SSunny Srivastava     // ToDo: Take offset value from user for hardware path.
266*fa5e4d32SSunny Srivastava 
267*fa5e4d32SSunny Srivastava     auto l_dumpObjFlag =
268*fa5e4d32SSunny Srivastava         l_app
269*fa5e4d32SSunny Srivastava             .add_flag("--dumpObject, -o",
270*fa5e4d32SSunny Srivastava                       "Dump specific properties of an inventory object")
271*fa5e4d32SSunny Srivastava             ->needs(l_objectOption);
272*fa5e4d32SSunny Srivastava 
273*fa5e4d32SSunny Srivastava     auto l_fixSystemVpdFlag = l_app.add_flag(
274*fa5e4d32SSunny Srivastava         "--fixSystemVPD",
275*fa5e4d32SSunny Srivastava         "Use this option to interactively fix critical system VPD keywords");
276*fa5e4d32SSunny Srivastava     auto l_dumpInventoryFlag =
277*fa5e4d32SSunny Srivastava         l_app.add_flag("--dumpInventory, -i", "Dump all the inventory objects");
278*fa5e4d32SSunny Srivastava 
279*fa5e4d32SSunny Srivastava     auto l_mfgCleanFlag = l_app.add_flag(
280*fa5e4d32SSunny Srivastava         "--mfgClean", "Manufacturing clean on system VPD keyword");
281*fa5e4d32SSunny Srivastava 
282*fa5e4d32SSunny Srivastava     auto l_mfgCleanConfirmFlag = l_app.add_flag(
283*fa5e4d32SSunny Srivastava         "--yes", "Using this flag with --mfgClean option, assumes "
284*fa5e4d32SSunny Srivastava                  "yes to proceed without confirmation.");
285*fa5e4d32SSunny Srivastava 
286*fa5e4d32SSunny Srivastava     auto l_dumpInventoryTableFlag =
287*fa5e4d32SSunny Srivastava         l_app.add_flag("--table, -t", "Dump inventory in table format");
288*fa5e4d32SSunny Srivastava 
289*fa5e4d32SSunny Srivastava     CLI11_PARSE(l_app, argc, argv);
290*fa5e4d32SSunny Srivastava 
291*fa5e4d32SSunny Srivastava     if (checkOptionValuePair(l_objectOption, l_vpdPath, l_recordOption,
292*fa5e4d32SSunny Srivastava                              l_recordName, l_keywordOption, l_keywordName) ==
293*fa5e4d32SSunny Srivastava         vpd::constants::FAILURE)
294*fa5e4d32SSunny Srivastava     {
295*fa5e4d32SSunny Srivastava         return vpd::constants::FAILURE;
296*fa5e4d32SSunny Srivastava     }
297*fa5e4d32SSunny Srivastava 
298*fa5e4d32SSunny Srivastava     if (!l_readFlag->empty())
299*fa5e4d32SSunny Srivastava     {
300*fa5e4d32SSunny Srivastava         return readKeyword(l_hardwareFlag, l_vpdPath, l_recordName,
301*fa5e4d32SSunny Srivastava                            l_keywordName, l_filePath);
302*fa5e4d32SSunny Srivastava     }
303*fa5e4d32SSunny Srivastava 
304*fa5e4d32SSunny Srivastava     if (!l_writeFlag->empty())
305*fa5e4d32SSunny Srivastava     {
306*fa5e4d32SSunny Srivastava         return writeKeyword(l_hardwareFlag, l_keywordValueOption, l_vpdPath,
307*fa5e4d32SSunny Srivastava                             l_recordName, l_keywordName, l_keywordValue);
308*fa5e4d32SSunny Srivastava     }
309*fa5e4d32SSunny Srivastava 
310*fa5e4d32SSunny Srivastava     if (!l_dumpObjFlag->empty())
311*fa5e4d32SSunny Srivastava     {
312*fa5e4d32SSunny Srivastava         vpd::VpdTool l_vpdToolObj;
313*fa5e4d32SSunny Srivastava         return l_vpdToolObj.dumpObject(l_vpdPath);
314*fa5e4d32SSunny Srivastava     }
315*fa5e4d32SSunny Srivastava 
316*fa5e4d32SSunny Srivastava     if (!l_fixSystemVpdFlag->empty())
317*fa5e4d32SSunny Srivastava     {
318*fa5e4d32SSunny Srivastava         vpd::VpdTool l_vpdToolObj;
319*fa5e4d32SSunny Srivastava         return l_vpdToolObj.fixSystemVpd();
320*fa5e4d32SSunny Srivastava     }
321*fa5e4d32SSunny Srivastava 
322*fa5e4d32SSunny Srivastava     if (!l_mfgCleanFlag->empty())
323*fa5e4d32SSunny Srivastava     {
324*fa5e4d32SSunny Srivastava         return doMfgClean(l_mfgCleanConfirmFlag);
325*fa5e4d32SSunny Srivastava     }
326*fa5e4d32SSunny Srivastava 
327*fa5e4d32SSunny Srivastava     if (!l_dumpInventoryFlag->empty())
328*fa5e4d32SSunny Srivastava     {
329*fa5e4d32SSunny Srivastava         vpd::VpdTool l_vpdToolObj;
330*fa5e4d32SSunny Srivastava         return l_vpdToolObj.dumpInventory(!l_dumpInventoryTableFlag->empty());
331*fa5e4d32SSunny Srivastava     }
332*fa5e4d32SSunny Srivastava 
333*fa5e4d32SSunny Srivastava     std::cout << l_app.help() << std::endl;
334*fa5e4d32SSunny Srivastava     return vpd::constants::FAILURE;
335*fa5e4d32SSunny Srivastava }
336