cli-parser (#4)
All checks were successful
Build ptprnt / build (push) Successful in 1m22s

Goal of this PR should be to integrate a working CLI parser so that commands can be sent to the Printer class to print text, such as
ptprnt -t=FooBar
also, standard flags for setting the output verbosity and help should be implemented

Reviewed-on: #4
This commit is contained in:
2023-10-22 19:42:59 +00:00
parent 7d0cb89bda
commit 9a1aee6658
11 changed files with 197 additions and 53 deletions

View File

@@ -29,10 +29,11 @@
#include "libusbwrap/interface/IUsbDevice.hpp"
namespace libusbwrap {
UsbDeviceFactory::UsbDeviceFactory() {}
UsbDeviceFactory::~UsbDeviceFactory() {
libusb_free_device_list(mLibusbDeviceList, 1);
if (mDeviceListInitialized) {
libusb_free_device_list(mLibusbDeviceList, 1);
}
}
std::vector<std::shared_ptr<IUsbDevice>> UsbDeviceFactory::findAllDevices() {
@@ -52,7 +53,7 @@ int UsbDeviceFactory::refreshDeviceList() {
} else if (ret == 0) {
spdlog::warn("No USB devices found");
}
mDeviceListInitialized = true;
return ret;
}

View File

@@ -24,12 +24,14 @@
namespace libusbwrap {
class UsbDeviceFactory : public IUsbDeviceFactory {
public:
UsbDeviceFactory();
~UsbDeviceFactory();
UsbDeviceFactory() = default;
virtual ~UsbDeviceFactory();
// delete copy ctor and assignment
UsbDeviceFactory(const UsbDeviceFactory&) = delete;
UsbDeviceFactory& operator=(UsbDeviceFactory&) = delete;
UsbDeviceFactory(const UsbDeviceFactory&) = delete;
UsbDeviceFactory& operator=(UsbDeviceFactory&) = delete;
UsbDeviceFactory(UsbDeviceFactory&&) = delete;
UsbDeviceFactory& operator=(UsbDeviceFactory&&) = delete;
bool init();
/**
@@ -56,6 +58,7 @@ class UsbDeviceFactory : public IUsbDeviceFactory {
uint16_t pid);
// members
libusb_context* mLibusbCtx{nullptr};
libusb_device** mLibusbDeviceList;
libusb_device** mLibusbDeviceList{};
bool mDeviceListInitialized = false;
};
} // namespace libusbwrap