2021-12-03 21:40:19 +00:00
|
|
|
// Copyright 2021 Dolphin Emulator Project
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
|
|
|
#include <cstdio>
|
2023-06-15 04:27:14 +00:00
|
|
|
#include <cstdlib>
|
2021-12-03 21:40:19 +00:00
|
|
|
#include <cstring>
|
|
|
|
#include <iostream>
|
|
|
|
#include <string>
|
2023-06-14 20:14:03 +00:00
|
|
|
#include <string_view>
|
2021-12-03 21:40:19 +00:00
|
|
|
#include <vector>
|
|
|
|
|
2023-06-16 23:59:30 +00:00
|
|
|
#include <fmt/format.h>
|
|
|
|
#include <fmt/ostream.h>
|
|
|
|
|
2023-06-14 23:33:11 +00:00
|
|
|
#include "Common/StringUtil.h"
|
2021-12-03 21:40:19 +00:00
|
|
|
#include "Common/Version.h"
|
2023-06-02 16:00:51 +00:00
|
|
|
#include "Core/Core.h"
|
2023-06-14 23:33:11 +00:00
|
|
|
|
2021-12-03 21:40:19 +00:00
|
|
|
#include "DolphinTool/ConvertCommand.h"
|
2022-02-24 10:51:52 +00:00
|
|
|
#include "DolphinTool/HeaderCommand.h"
|
2021-12-03 21:40:19 +00:00
|
|
|
#include "DolphinTool/VerifyCommand.h"
|
|
|
|
|
2023-06-15 04:27:14 +00:00
|
|
|
static void PrintUsage()
|
2021-12-03 21:40:19 +00:00
|
|
|
{
|
2023-06-16 23:59:30 +00:00
|
|
|
fmt::print(std::cerr, "usage: dolphin-tool COMMAND -h\n"
|
|
|
|
"\n"
|
|
|
|
"commands supported: [convert, verify, header]\n");
|
2021-12-03 21:40:19 +00:00
|
|
|
}
|
|
|
|
|
2022-03-08 07:22:35 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
#define main app_main
|
|
|
|
#endif
|
|
|
|
|
2021-12-03 21:40:19 +00:00
|
|
|
int main(int argc, char* argv[])
|
|
|
|
{
|
2023-06-02 16:00:51 +00:00
|
|
|
Core::DeclareAsHostThread();
|
|
|
|
|
2021-12-03 21:40:19 +00:00
|
|
|
if (argc < 2)
|
2023-06-15 04:27:14 +00:00
|
|
|
{
|
|
|
|
PrintUsage();
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
2021-12-03 21:40:19 +00:00
|
|
|
|
2023-06-14 20:14:03 +00:00
|
|
|
const std::string_view command_str = argv[1];
|
|
|
|
// Take off the program name and command selector before passing arguments down
|
|
|
|
const std::vector<std::string> args(argv + 2, argv + argc);
|
2021-12-03 21:40:19 +00:00
|
|
|
|
|
|
|
if (command_str == "convert")
|
2023-06-14 23:33:11 +00:00
|
|
|
return DolphinTool::ConvertCommand(args);
|
2021-12-03 21:40:19 +00:00
|
|
|
else if (command_str == "verify")
|
2023-06-14 23:33:11 +00:00
|
|
|
return DolphinTool::VerifyCommand(args);
|
2022-02-24 10:51:52 +00:00
|
|
|
else if (command_str == "header")
|
2023-06-14 23:33:11 +00:00
|
|
|
return DolphinTool::HeaderCommand(args);
|
2023-06-15 04:27:14 +00:00
|
|
|
PrintUsage();
|
|
|
|
return EXIT_FAILURE;
|
2021-12-03 21:40:19 +00:00
|
|
|
}
|
2022-03-08 07:22:35 +00:00
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
int wmain(int, wchar_t*[], wchar_t*[])
|
|
|
|
{
|
2023-05-16 18:23:21 +00:00
|
|
|
std::vector<std::string> args = Common::CommandLineToUtf8Argv(GetCommandLineW());
|
2022-03-08 07:22:35 +00:00
|
|
|
const int argc = static_cast<int>(args.size());
|
|
|
|
std::vector<char*> argv(args.size());
|
|
|
|
for (size_t i = 0; i < args.size(); ++i)
|
|
|
|
argv[i] = args[i].data();
|
|
|
|
|
|
|
|
return main(argc, argv.data());
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef main
|
|
|
|
#endif
|