Skip to content

Commit

Permalink
fix: build error on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
MistEO committed Feb 13, 2024
1 parent b24a456 commit 0c733c4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
25 changes: 13 additions & 12 deletions source/MaaProjectInterfaceCli/interactor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,22 @@
#include <unordered_set>

#include "MaaToolkit/Device/MaaToolkitDevice.h"
#include "Utils/Format.hpp"
#include "Utils/Logger.h"
#include "Utils/Platform.h"

// return [1, size]
int input(size_t size, std::string_view prompt = "Please input")
{
std::cout << std::format("{} [1-{}]: ", prompt, size);
std::cout << MAA_FMT::format("{} [1-{}]: ", prompt, size);
size_t value = 0;

while (true) {
std::cin >> value;
if (value > 0 && value <= size) {
break;
}
std::cout << std::format("Invalid value, {} [1-{}]: ", prompt, size);
std::cout << MAA_FMT::format("Invalid value, {} [1-{}]: ", prompt, size);
}

return static_cast<int>(value);
Expand Down Expand Up @@ -83,9 +84,9 @@ void Interactor::print_config() const

std::cout << "Controller:\n\n";
std::cout << "\t"
<< MaaNS::utf8_to_crt(std::format("ADB\n\t\t{}\n\t\t{}",
MaaNS::path_to_utf8_string(config_.configuration().adb_param.adb_path),
config_.configuration().adb_param.address))
<< MaaNS::utf8_to_crt(MAA_FMT::format(
"ADB\n\t\t{}\n\t\t{}", MaaNS::path_to_utf8_string(config_.configuration().adb_param.adb_path),
config_.configuration().adb_param.address))
<< "\n\n";

std::cout << "Resource:\n\n";
Expand Down Expand Up @@ -173,7 +174,7 @@ void Interactor::select_adb_auto_detect()
std::string path = MaaToolkitGetDeviceAdbPath(i);
std::string address = MaaToolkitGetDeviceAdbSerial(i);

std::cout << MaaNS::utf8_to_crt(std::format("\t{}. {}\n\t\t{}\n\t\t{}\n", i + 1, name, path, address));
std::cout << MaaNS::utf8_to_crt(MAA_FMT::format("\t{}. {}\n\t\t{}\n\t\t{}\n", i + 1, name, path, address));
}
std::cout << "\n";

Expand Down Expand Up @@ -214,7 +215,7 @@ void Interactor::select_resource()
std::cout << "\n\n\n";
std::cout << "### Select resource ###\n\n";
for (size_t i = 0; i < all_resources.size(); ++i) {
std::cout << MaaNS::utf8_to_crt(std::format("\t{}. {}\n", i + 1, all_resources[i].name));
std::cout << MaaNS::utf8_to_crt(MAA_FMT::format("\t{}. {}\n", i + 1, all_resources[i].name));
}
std::cout << "\n";
index = input(all_resources.size()) - 1;
Expand Down Expand Up @@ -242,7 +243,7 @@ void Interactor::add_task()
std::cout << "\n\n\n";
std::cout << "### Add task ###\n\n";
for (size_t i = 0; i < all_data_tasks.size(); ++i) {
std::cout << MaaNS::utf8_to_crt(std::format("\t{}. {}\n", i + 1, all_data_tasks[i].name));
std::cout << MaaNS::utf8_to_crt(MAA_FMT::format("\t{}. {}\n", i + 1, all_data_tasks[i].name));
}
std::cout << "\n";
int input_index = input(all_data_tasks.size()) - 1;
Expand All @@ -261,9 +262,9 @@ void Interactor::add_task()
config_options.emplace_back(Configuration::Option { option_name, opt.default_case });
continue;
}
std::cout << MaaNS::utf8_to_crt(std::format("\n\n\n## Input option for \"{}\" ##\n\n", option_name));
std::cout << MaaNS::utf8_to_crt(MAA_FMT::format("\n\n\n## Input option for \"{}\" ##\n\n", option_name));
for (size_t i = 0; i < opt.cases.size(); ++i) {
std::cout << MaaNS::utf8_to_crt(std::format("\t{}. {}\n", i + 1, opt.cases[i].name));
std::cout << MaaNS::utf8_to_crt(MAA_FMT::format("\t{}. {}\n", i + 1, opt.cases[i].name));
}
std::cout << "\n";

Expand Down Expand Up @@ -328,10 +329,10 @@ void Interactor::print_config_tasks(bool with_index) const
for (size_t i = 0; i < all_config_tasks.size(); ++i) {
const auto& task = all_config_tasks[i];
if (with_index) {
std::cout << MaaNS::utf8_to_crt(std::format("\t{}. {}\n", i + 1, task.name));
std::cout << MaaNS::utf8_to_crt(MAA_FMT::format("\t{}. {}\n", i + 1, task.name));
}
else {
std::cout << MaaNS::utf8_to_crt(std::format("\t- {}\n", task.name));
std::cout << MaaNS::utf8_to_crt(MAA_FMT::format("\t- {}\n", task.name));
}

for (const auto& [key, value] : task.option) {
Expand Down
3 changes: 2 additions & 1 deletion source/MaaProjectInterfaceCli/runner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "MaaFramework/MaaAPI.h"
#include "MaaToolkit/MaaToolkitAPI.h"

#include "Utils/Format.hpp"
#include "Utils/ScopeLeave.hpp"

bool Runner::run(const MAA_PROJECT_INTERFACE_NS::RuntimeParam& param)
Expand Down Expand Up @@ -76,5 +77,5 @@ void Runner::on_maafw_notify(MaaStringView msg, MaaStringView details_json, MaaT
std::ignore = callback_arg;

std::string entry = json::parse(details_json).value_or(json::value())["entry"].as_string();
std::cout << std::format("on_maafw_notify: {} {}", msg, entry) << std::endl;
std::cout << MAA_FMT::format("on_maafw_notify: {} {}", msg, entry) << std::endl;
}

0 comments on commit 0c733c4

Please sign in to comment.