-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cpp
47 lines (34 loc) · 1.27 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <iostream>
#include "cxxopts.hpp"
#include "xp58.h"
int main(int argc, char **argv)
{
cxxopts::Options options("xp58tool", "A tool to control Xp-58 printer.");
options.allow_unrecognised_options();
options.add_options()
("d,device", "Xp-58 device path", cxxopts::value<std::string>()->default_value("/dev/usb/lp0"))
("t,text", "Text", cxxopts::value<std::string>())
("s,size", "Text size", cxxopts::value<uint8_t>()->default_value("1"))
("r,reverse", "Enable reverse mode", cxxopts::value<bool>()->default_value("false"))
("h,help", "Help");
auto result = options.parse(argc, argv);
if (result.count("help") || result.count("text") == 0)
{
std::cout << options.help() << std::endl;
exit(0);
}
std::cout << "Start printing..." << std::endl;
Xp58 printer(result["device"].as<std::string>().c_str());
if (result["size"].as<uint8_t>() != 1)
{
printer.SetCharacterSize(result["size"].as<uint8_t>(), result["size"].as<uint8_t>());
}
if (result["reverse"].as<bool>())
{
printer.ReverseModeOn();
}
printer.PrintLine(result["text"].as<std::string>());
printer.FeedNLines(2);
std::cout << "Finish." << std::endl;
return 0;
}