1 #include "usb_manager.hpp"
2 
3 #include <CLI/CLI.hpp>
4 #include <phosphor-logging/lg2.hpp>
5 
6 int main(int argc, char** argv)
7 {
8     namespace fs = std::filesystem;
9 
10     std::string fileName{};
11 
12     CLI::App app{"Update the firmware of OpenBMC via USB app"};
13     app.add_option("-f,--fileName", fileName,
14                    "Get the name of the USB mount folder, eg: sda1, sdb1");
15 
16     CLI11_PARSE(app, argc, argv);
17 
18     if (fileName.empty())
19     {
20         lg2::error("The file name passed in is empty.");
21         return -1;
22     }
23 
24     fs::path usbPath = fs::path{"/run/media/usb"} / fileName;
25     phosphor::usb::USBManager manager(usbPath);
26 
27     if (!manager.run())
28     {
29         lg2::error("Failed to FW Update via USB, usbPath:{USBPATH}", "USBPATH",
30                    usbPath);
31         return -1;
32     }
33 
34     return 0;
35 }
36