All checks were successful
Build ptprnt / build (push) Successful in 3m47s
Reviewed-on: moritz/ptouch-prnt#17
80 lines
2.3 KiB
C++
80 lines
2.3 KiB
C++
/*
|
|
ptrnt - print labels on linux
|
|
Copyright (C) 2025 Moritz Martinius
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace ptprnt::cli {
|
|
|
|
/**
|
|
* @brief Types of CLI commands that can be issued
|
|
*/
|
|
enum class CommandType { None = 0, Text = 1, FontSize = 2, Font = 3, VAlign = 4, HAlign = 5, NewLabel = 6 };
|
|
|
|
/**
|
|
* @brief A command with its type and value
|
|
*/
|
|
using Command = std::pair<CommandType, std::string>;
|
|
|
|
/**
|
|
* @brief Parsed CLI options and commands
|
|
*/
|
|
struct CliOptions {
|
|
bool verbose{false};
|
|
bool trace{false};
|
|
bool listDrivers{false};
|
|
std::string printerSelection{"auto"};
|
|
std::vector<Command> commands{};
|
|
};
|
|
|
|
/**
|
|
* @brief Interface for CLI argument parsing
|
|
*
|
|
* This interface allows for mocking CLI parsing in unit tests
|
|
* and provides a clear contract for CLI parser implementations.
|
|
*/
|
|
class ICliParser {
|
|
public:
|
|
virtual ~ICliParser() = default;
|
|
|
|
ICliParser() = default;
|
|
ICliParser(const ICliParser&) = default;
|
|
ICliParser& operator=(const ICliParser&) = default;
|
|
ICliParser(ICliParser&&) noexcept = default;
|
|
ICliParser& operator=(ICliParser&&) noexcept = default;
|
|
|
|
/**
|
|
* @brief Parse command line arguments
|
|
* @param argc Argument count
|
|
* @param argv Argument values
|
|
* @return 0 on success, positive value if should exit immediately (help/version), negative on error
|
|
*/
|
|
virtual int parse(int argc, char** argv) = 0;
|
|
|
|
/**
|
|
* @brief Get the parsed options
|
|
* @return Reference to parsed options
|
|
*/
|
|
[[nodiscard]] virtual const CliOptions& getOptions() const = 0;
|
|
};
|
|
|
|
} // namespace ptprnt::cli
|