1 #include "usb_manager.hpp"
2 
3 #include <CLI/CLI.hpp>
4 #include <phosphor-logging/lg2.hpp>
5 #include <sdeventplus/event.hpp>
6 
main(int argc,char ** argv)7 int main(int argc, char** argv)
8 {
9     namespace fs = std::filesystem;
10     // Dbus constructs
11     auto bus = sdbusplus::bus::new_default();
12 
13     // Get a default event loop
14     auto event = sdeventplus::Event::get_default();
15 
16     std::string deviceName{};
17 
18     CLI::App app{"Update the firmware of OpenBMC via USB app"};
19     app.add_option("-d,--device", deviceName,
20                    "Get the name of the USB device name, eg: sda1, sdb1");
21 
22     CLI11_PARSE(app, argc, argv);
23 
24     if (deviceName.empty())
25     {
26         lg2::error("The file name passed in is empty.");
27         return -1;
28     }
29 
30     fs::path devicePath = fs::path{"/dev"} / deviceName;
31     fs::path usbPath = fs::path{"/run/media/usb"} / deviceName;
32     phosphor::usb::USBManager manager(bus, event, devicePath, usbPath);
33 
34     // Attach the bus to sd_event to service user requests
35     bus.attach_event(event.get(), SD_EVENT_PRIORITY_NORMAL);
36     event.loop();
37 
38     return 0;
39 }
40