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:
@@ -19,23 +19,47 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <CLI/CLI.hpp>
|
||||
#include <spdlog/common.h>
|
||||
#include <spdlog/spdlog.h>
|
||||
|
||||
#include "constants.hpp"
|
||||
#include "interface/IPrinterDriver.hpp"
|
||||
#include "libusbwrap/UsbDeviceFactory.hpp"
|
||||
|
||||
namespace ptprnt {
|
||||
enum class CliCmdType { None = 0, Text = 1, FontSize = 2, Font = 3, VAlign = 4, HAlign = 5 };
|
||||
using CliCmd = std::pair<CliCmdType, std::string>;
|
||||
|
||||
class PtouchPrint {
|
||||
public:
|
||||
PtouchPrint();
|
||||
~PtouchPrint();
|
||||
PtouchPrint(const char* versionString);
|
||||
~PtouchPrint() = default;
|
||||
|
||||
void init();
|
||||
void run();
|
||||
// This is basically a singelton application class, no need to copy or move
|
||||
PtouchPrint(const PtouchPrint&) = delete;
|
||||
PtouchPrint& operator=(const PtouchPrint&) = delete;
|
||||
PtouchPrint(PtouchPrint&&) = delete;
|
||||
PtouchPrint& operator=(PtouchPrint&&) = delete;
|
||||
|
||||
int init(int argc, char** argv);
|
||||
int run();
|
||||
|
||||
private:
|
||||
// methods
|
||||
void setupLogger(spdlog::level::level_enum lvl);
|
||||
void setupCliParser();
|
||||
unsigned int getCompatiblePrinters();
|
||||
|
||||
// member variables
|
||||
libusbwrap::UsbDeviceFactory mUsbDeviceFactory;
|
||||
std::vector<std::shared_ptr<ptprnt::IPrinterDriver>> mCompatiblePrinters;
|
||||
std::vector<std::shared_ptr<ptprnt::IPrinterDriver>> mDetectedPrinters;
|
||||
};
|
||||
CLI::App mApp{ptprnt::APP_DESC};
|
||||
libusbwrap::UsbDeviceFactory mUsbDeviceFactory{};
|
||||
std::vector<std::shared_ptr<ptprnt::IPrinterDriver>> mCompatiblePrinters{};
|
||||
std::vector<std::shared_ptr<ptprnt::IPrinterDriver>> mDetectedPrinters{};
|
||||
std::vector<CliCmd> mCommands{};
|
||||
std::string mVersionString = "";
|
||||
|
||||
// CLI flags
|
||||
bool mVerboseFlag = false;
|
||||
};
|
||||
} // namespace ptprnt
|
Reference in New Issue
Block a user