69 lines
2.1 KiB
C++
69 lines
2.1 KiB
C++
#pragma once
|
|
#include "Utils.hpp"
|
|
#include "Reporter.hpp"
|
|
#include <yycc.hpp>
|
|
#include <yycc/macro/class_copy_move.hpp>
|
|
#include <string>
|
|
#include <optional>
|
|
#include <expected>
|
|
|
|
namespace BMapInspector::Cli {
|
|
|
|
enum class RequestKind {
|
|
Help,
|
|
Version,
|
|
Work,
|
|
};
|
|
|
|
class Request {
|
|
public:
|
|
static Request FromHelpRequest();
|
|
static Request FromVersionRequest();
|
|
static Request FromWorkRequest(Utils::ReportLevel level,
|
|
const std::u8string_view& file_path,
|
|
const std::u8string_view& encoding,
|
|
const std::u8string_view& ballance_path);
|
|
|
|
private:
|
|
Request(RequestKind kind,
|
|
std::optional<Utils::ReportLevel> level,
|
|
std::optional<std::u8string_view> file_path,
|
|
std::optional<std::u8string_view> encoding,
|
|
std::optional<std::u8string_view> ballance_path);
|
|
|
|
public:
|
|
~Request();
|
|
YYCC_DEFAULT_COPY_MOVE(Request)
|
|
|
|
public:
|
|
RequestKind GetRequestKind() const;
|
|
Utils::ReportLevel GetLevel() const;
|
|
std::u8string_view GetFilePath() const;
|
|
std::u8string_view GetEncoding() const;
|
|
std::u8string_view GetBallancePath() const;
|
|
|
|
private:
|
|
RequestKind kind; ///< The kind of this request.
|
|
std::optional<Utils::ReportLevel> level; ///< The filter level.
|
|
std::optional<std::u8string> file_path; ///< The path to loaded map file.
|
|
std::optional<std::u8string> encoding; ///< The encoding used when loading map file.
|
|
std::optional<std::u8string> ballance_path; ///< The path to Ballance root directory for loading resources.
|
|
};
|
|
|
|
enum class Error {
|
|
BadParse, ///< Error occurs when executing parser.
|
|
NoFile, ///< User do not specify file path for loading.
|
|
BadFile, ///< User specified file path is bad.
|
|
NoBallance, ///< User do not specify Ballance directory for loading.
|
|
BadBallance, ///< User specified Ballance directory is bad.
|
|
BadEncoding, ///< User given encoding value is bad.
|
|
BadLevel, ///< User given level name is bad.
|
|
};
|
|
|
|
template<typename T>
|
|
using Result = std::expected<T, Error>;
|
|
|
|
Result<Request> parse();
|
|
|
|
} // namespace BMapInspector::Cli
|