mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-20 00:02:55 +00:00
chore: improve args code for other tools
This commit is contained in:
parent
c37e9984ba
commit
da18291c89
@ -7,6 +7,7 @@
|
|||||||
#include "Utils/FileUtils.h"
|
#include "Utils/FileUtils.h"
|
||||||
|
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
#include <format>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <regex>
|
#include <regex>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
@ -155,7 +156,7 @@ void LinkerArgs::PrintUsage()
|
|||||||
|
|
||||||
void LinkerArgs::PrintVersion()
|
void LinkerArgs::PrintVersion()
|
||||||
{
|
{
|
||||||
std::cout << "OpenAssetTools Linker " << std::string(GIT_VERSION) << "\n";
|
std::cout << std::format("OpenAssetTools Linker {}\n", GIT_VERSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LinkerArgs::SetBinFolder(const char* argv0)
|
void LinkerArgs::SetBinFolder(const char* argv0)
|
||||||
|
@ -4,38 +4,55 @@
|
|||||||
#include "Utils/Arguments/CommandLineOption.h"
|
#include "Utils/Arguments/CommandLineOption.h"
|
||||||
#include "Utils/Arguments/UsageInformation.h"
|
#include "Utils/Arguments/UsageInformation.h"
|
||||||
|
|
||||||
|
#include <format>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
|
// clang-format off
|
||||||
const CommandLineOption* const OPTION_HELP =
|
const CommandLineOption* const OPTION_HELP =
|
||||||
CommandLineOption::Builder::Create().WithShortName("?").WithLongName("help").WithDescription("Displays usage information.").Build();
|
CommandLineOption::Builder::Create()
|
||||||
|
.WithShortName("?")
|
||||||
|
.WithLongName("help")
|
||||||
|
.WithDescription("Displays usage information.")
|
||||||
|
.Build();
|
||||||
|
|
||||||
const CommandLineOption* const OPTION_VERSION =
|
const CommandLineOption* const OPTION_VERSION =
|
||||||
CommandLineOption::Builder::Create().WithLongName("version").WithDescription("Prints the application version.").Build();
|
CommandLineOption::Builder::Create()
|
||||||
|
.WithLongName("version")
|
||||||
|
.WithDescription("Prints the application version.")
|
||||||
|
.Build();
|
||||||
|
|
||||||
const CommandLineOption* const OPTION_VERBOSE =
|
const CommandLineOption* const OPTION_VERBOSE =
|
||||||
CommandLineOption::Builder::Create().WithShortName("v").WithLongName("verbose").WithDescription("Outputs a lot more and more detailed messages.").Build();
|
CommandLineOption::Builder::Create()
|
||||||
|
.WithShortName("v")
|
||||||
|
.WithLongName("verbose")
|
||||||
|
.WithDescription("Outputs a lot more and more detailed messages.")
|
||||||
|
.Build();
|
||||||
|
|
||||||
const CommandLineOption* const OPTION_OUTPUT_FOLDER = CommandLineOption::Builder::Create()
|
const CommandLineOption* const OPTION_OUTPUT_FOLDER =
|
||||||
|
CommandLineOption::Builder::Create()
|
||||||
.WithShortName("o")
|
.WithShortName("o")
|
||||||
.WithLongName("output")
|
.WithLongName("output")
|
||||||
.WithDescription("Specify the folder to save the generated files. Defaults to the current directory.")
|
.WithDescription("Specify the folder to save the generated files. Defaults to the current directory.")
|
||||||
.WithParameter("outputPath")
|
.WithParameter("outputPath")
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
const CommandLineOption* const OPTION_BUILD_LOG = CommandLineOption::Builder::Create()
|
const CommandLineOption* const OPTION_BUILD_LOG =
|
||||||
|
CommandLineOption::Builder::Create()
|
||||||
.WithLongName("build-log")
|
.WithLongName("build-log")
|
||||||
.WithDescription("Specify a file to write a build log to.")
|
.WithDescription("Specify a file to write a build log to.")
|
||||||
.WithParameter("logFilePath")
|
.WithParameter("logFilePath")
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
const CommandLineOption* const OPTION_DEFINE = CommandLineOption::Builder::Create()
|
const CommandLineOption* const OPTION_DEFINE =
|
||||||
|
CommandLineOption::Builder::Create()
|
||||||
.WithShortName("d")
|
.WithShortName("d")
|
||||||
.WithLongName("define")
|
.WithLongName("define")
|
||||||
.WithDescription("Adds a define for the templating process. Can be of format define or define=value.")
|
.WithDescription("Adds a define for the templating process. Can be of format define or define=value.")
|
||||||
.WithParameter("defineValue")
|
.WithParameter("defineValue")
|
||||||
.Reusable()
|
.Reusable()
|
||||||
.Build();
|
.Build();
|
||||||
|
// clang-format on
|
||||||
|
|
||||||
const CommandLineOption* const COMMAND_LINE_OPTIONS[]{
|
const CommandLineOption* const COMMAND_LINE_OPTIONS[]{
|
||||||
OPTION_HELP,
|
OPTION_HELP,
|
||||||
@ -66,7 +83,7 @@ void RawTemplaterArguments::PrintUsage()
|
|||||||
|
|
||||||
void RawTemplaterArguments::PrintVersion()
|
void RawTemplaterArguments::PrintVersion()
|
||||||
{
|
{
|
||||||
std::cout << "OpenAssetTools RawTemplater " << std::string(GIT_VERSION) << "\n";
|
std::cout << std::format("OpenAssetTools RawTemplater {}\n", GIT_VERSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RawTemplaterArguments::ParseArgs(const int argc, const char** argv, bool& shouldContinue)
|
bool RawTemplaterArguments::ParseArgs(const int argc, const char** argv, bool& shouldContinue)
|
||||||
@ -122,9 +139,9 @@ bool RawTemplaterArguments::ParseArgs(const int argc, const char** argv, bool& s
|
|||||||
const auto separator = arg.find('=');
|
const auto separator = arg.find('=');
|
||||||
|
|
||||||
if (separator != std::string::npos)
|
if (separator != std::string::npos)
|
||||||
m_defines.emplace_back(std::make_pair(arg.substr(0, separator), arg.substr(separator + 1)));
|
m_defines.emplace_back(arg.substr(0, separator), arg.substr(separator + 1));
|
||||||
else
|
else
|
||||||
m_defines.emplace_back(std::make_pair(arg, std::string()));
|
m_defines.emplace_back(arg, std::string());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include "Utils/FileUtils.h"
|
#include "Utils/FileUtils.h"
|
||||||
#include "Utils/StringUtils.h"
|
#include "Utils/StringUtils.h"
|
||||||
|
|
||||||
|
#include <format>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <regex>
|
#include <regex>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
@ -167,7 +168,7 @@ void UnlinkerArgs::PrintUsage()
|
|||||||
|
|
||||||
void UnlinkerArgs::PrintVersion()
|
void UnlinkerArgs::PrintVersion()
|
||||||
{
|
{
|
||||||
std::cout << "OpenAssetTools Unlinker " << std::string(GIT_VERSION) << "\n";
|
std::cout << std::format("OpenAssetTools Unlinker {}\n", GIT_VERSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnlinkerArgs::SetVerbose(const bool isVerbose)
|
void UnlinkerArgs::SetVerbose(const bool isVerbose)
|
||||||
|
@ -4,25 +4,35 @@
|
|||||||
#include "Utils/Arguments/CommandLineOption.h"
|
#include "Utils/Arguments/CommandLineOption.h"
|
||||||
#include "Utils/Arguments/UsageInformation.h"
|
#include "Utils/Arguments/UsageInformation.h"
|
||||||
|
|
||||||
|
#include <format>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
|
// clang-format off
|
||||||
const CommandLineOption* const OPTION_HELP =
|
const CommandLineOption* const OPTION_HELP =
|
||||||
CommandLineOption::Builder::Create().WithShortName("?").WithLongName("help").WithDescription("Displays usage information.").Build();
|
CommandLineOption::Builder::Create()
|
||||||
|
.WithShortName("?")
|
||||||
|
.WithLongName("help")
|
||||||
|
.WithDescription("Displays usage information.")
|
||||||
|
.Build();
|
||||||
|
|
||||||
const CommandLineOption* const OPTION_VERSION =
|
const CommandLineOption* const OPTION_VERSION =
|
||||||
CommandLineOption::Builder::Create().WithLongName("version").WithDescription("Prints the application version.").Build();
|
CommandLineOption::Builder::Create()
|
||||||
|
.WithLongName("version")
|
||||||
|
.WithDescription("Prints the application version.")
|
||||||
|
.Build();
|
||||||
|
|
||||||
const CommandLineOption* const OPTION_VERBOSE =
|
const CommandLineOption* const OPTION_VERBOSE =
|
||||||
CommandLineOption::Builder::Create().WithShortName("v").WithLongName("verbose").WithDescription("Outputs a lot more and more detailed messages.").Build();
|
CommandLineOption::Builder::Create()
|
||||||
|
.WithShortName("v")
|
||||||
|
.WithLongName("verbose")
|
||||||
|
.WithDescription("Outputs a lot more and more detailed messages.")
|
||||||
|
.Build();
|
||||||
|
|
||||||
// ------
|
constexpr auto CATEGORY_INPUT = "Input";
|
||||||
// INPUT
|
|
||||||
// ------
|
|
||||||
|
|
||||||
constexpr const char* CATEGORY_INPUT = "Input";
|
const CommandLineOption* const OPTION_HEADER =
|
||||||
|
CommandLineOption::Builder::Create()
|
||||||
const CommandLineOption* const OPTION_HEADER = CommandLineOption::Builder::Create()
|
|
||||||
.WithShortName("h")
|
.WithShortName("h")
|
||||||
.WithLongName("header")
|
.WithLongName("header")
|
||||||
.WithDescription("Reads from the specified header file.")
|
.WithDescription("Reads from the specified header file.")
|
||||||
@ -31,7 +41,8 @@ const CommandLineOption* const OPTION_HEADER = CommandLineOption::Builder::Creat
|
|||||||
.Reusable()
|
.Reusable()
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
const CommandLineOption* const OPTION_COMMANDS_FILE = CommandLineOption::Builder::Create()
|
const CommandLineOption* const OPTION_COMMANDS_FILE =
|
||||||
|
CommandLineOption::Builder::Create()
|
||||||
.WithShortName("c")
|
.WithShortName("c")
|
||||||
.WithLongName("commands-file")
|
.WithLongName("commands-file")
|
||||||
.WithDescription("Specifies the commands file. Defaults to stdin.")
|
.WithDescription("Specifies the commands file. Defaults to stdin.")
|
||||||
@ -40,10 +51,7 @@ const CommandLineOption* const OPTION_COMMANDS_FILE = CommandLineOption::Builder
|
|||||||
.Reusable()
|
.Reusable()
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
// ------
|
constexpr auto CATEGORY_OUTPUT = "Output";
|
||||||
// OUTPUT
|
|
||||||
// ------
|
|
||||||
constexpr const char* CATEGORY_OUTPUT = "Output";
|
|
||||||
|
|
||||||
const CommandLineOption* const OPTION_OUTPUT_FOLDER =
|
const CommandLineOption* const OPTION_OUTPUT_FOLDER =
|
||||||
CommandLineOption::Builder::Create()
|
CommandLineOption::Builder::Create()
|
||||||
@ -54,7 +62,8 @@ const CommandLineOption* const OPTION_OUTPUT_FOLDER =
|
|||||||
.WithParameter("outputPath")
|
.WithParameter("outputPath")
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
const CommandLineOption* const OPTION_PRINT = CommandLineOption::Builder::Create()
|
const CommandLineOption* const OPTION_PRINT =
|
||||||
|
CommandLineOption::Builder::Create()
|
||||||
.WithShortName("p")
|
.WithShortName("p")
|
||||||
.WithLongName("print")
|
.WithLongName("print")
|
||||||
.WithDescription("Print the loaded data.")
|
.WithDescription("Print the loaded data.")
|
||||||
@ -65,13 +74,13 @@ const CommandLineOption* const OPTION_GENERATE =
|
|||||||
CommandLineOption::Builder::Create()
|
CommandLineOption::Builder::Create()
|
||||||
.WithShortName("g")
|
.WithShortName("g")
|
||||||
.WithLongName("generate")
|
.WithLongName("generate")
|
||||||
.WithDescription("Generates a specified asset/preset combination. Can be used multiple times. Available presets: "
|
.WithDescription("Generates a specified asset/preset combination. Can be used multiple times. Available presets: ZoneLoad, ZoneWrite, AssetStructTests")
|
||||||
"ZoneLoad, ZoneWrite, AssetStructTests")
|
|
||||||
.WithCategory(CATEGORY_OUTPUT)
|
.WithCategory(CATEGORY_OUTPUT)
|
||||||
.WithParameter("assetName")
|
.WithParameter("assetName")
|
||||||
.WithParameter("preset")
|
.WithParameter("preset")
|
||||||
.Reusable()
|
.Reusable()
|
||||||
.Build();
|
.Build();
|
||||||
|
// clang-format on
|
||||||
|
|
||||||
const CommandLineOption* const COMMAND_LINE_OPTIONS[]{
|
const CommandLineOption* const COMMAND_LINE_OPTIONS[]{
|
||||||
OPTION_HELP,
|
OPTION_HELP,
|
||||||
@ -123,7 +132,7 @@ void ZoneCodeGeneratorArguments::PrintUsage()
|
|||||||
|
|
||||||
void ZoneCodeGeneratorArguments::PrintVersion()
|
void ZoneCodeGeneratorArguments::PrintVersion()
|
||||||
{
|
{
|
||||||
std::cout << "OpenAssetTools ZoneCodeGenerator " << std::string(GIT_VERSION) << "\n";
|
std::cout << std::format("OpenAssetTools ZoneCodeGenerator {}\n", GIT_VERSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ZoneCodeGeneratorArguments::ParseArgs(const int argc, const char** argv, bool& shouldContinue)
|
bool ZoneCodeGeneratorArguments::ParseArgs(const int argc, const char** argv, bool& shouldContinue)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user