feat: add cli support for BMapInspector
This commit is contained in:
68
Ballance/BMapInspector/Cli.hpp
Normal file
68
Ballance/BMapInspector/Cli.hpp
Normal file
@@ -0,0 +1,68 @@
|
||||
#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
|
||||
Reference in New Issue
Block a user