mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-11 07:18:11 -05:00
feat: add version command line arg to all executables
This commit is contained in:
@ -613,9 +613,13 @@ public:
|
||||
|
||||
bool Start(const int argc, const char** argv) override
|
||||
{
|
||||
if (!m_args.ParseArgs(argc, argv))
|
||||
auto shouldContinue = true;
|
||||
if (!m_args.ParseArgs(argc, argv, shouldContinue))
|
||||
return false;
|
||||
|
||||
if (!shouldContinue)
|
||||
return true;
|
||||
|
||||
if (!m_search_paths.BuildProjectIndependentSearchPaths())
|
||||
return false;
|
||||
|
||||
|
@ -1,11 +1,13 @@
|
||||
#include "LinkerArgs.h"
|
||||
|
||||
#include "GitVersion.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "ObjWriting.h"
|
||||
#include "Utils/Arguments/UsageInformation.h"
|
||||
#include "Utils/FileUtils.h"
|
||||
|
||||
#include <filesystem>
|
||||
#include <iostream>
|
||||
#include <regex>
|
||||
#include <type_traits>
|
||||
|
||||
@ -19,6 +21,12 @@ const CommandLineOption* const OPTION_HELP =
|
||||
.WithDescription("Displays usage information.")
|
||||
.Build();
|
||||
|
||||
const CommandLineOption* const OPTION_VERSION =
|
||||
CommandLineOption::Builder::Create()
|
||||
.WithLongName("version")
|
||||
.WithDescription("Prints the application version.")
|
||||
.Build();
|
||||
|
||||
const CommandLineOption* const OPTION_VERBOSE =
|
||||
CommandLineOption::Builder::Create()
|
||||
.WithShortName("v")
|
||||
@ -88,6 +96,7 @@ const CommandLineOption* const OPTION_MENU_NO_OPTIMIZATION =
|
||||
|
||||
const CommandLineOption* const COMMAND_LINE_OPTIONS[]{
|
||||
OPTION_HELP,
|
||||
OPTION_VERSION,
|
||||
OPTION_VERBOSE,
|
||||
OPTION_BASE_FOLDER,
|
||||
OPTION_OUTPUT_FOLDER,
|
||||
@ -100,7 +109,7 @@ const CommandLineOption* const COMMAND_LINE_OPTIONS[]{
|
||||
};
|
||||
|
||||
LinkerArgs::LinkerArgs()
|
||||
: m_argument_parser(COMMAND_LINE_OPTIONS, std::extent<decltype(COMMAND_LINE_OPTIONS)>::value),
|
||||
: m_argument_parser(COMMAND_LINE_OPTIONS, std::extent_v<decltype(COMMAND_LINE_OPTIONS)>),
|
||||
m_base_pattern(R"(\?base\?)"),
|
||||
m_game_pattern(R"(\?game\?)"),
|
||||
m_project_pattern(R"(\?project\?)"),
|
||||
@ -125,6 +134,11 @@ void LinkerArgs::PrintUsage()
|
||||
usage.Print();
|
||||
}
|
||||
|
||||
void LinkerArgs::PrintVersion()
|
||||
{
|
||||
std::cout << "OpenAssetTools Linker " << std::string(GIT_VERSION) << "\n";
|
||||
}
|
||||
|
||||
void LinkerArgs::SetVerbose(const bool isVerbose)
|
||||
{
|
||||
m_verbose = isVerbose;
|
||||
@ -198,8 +212,9 @@ std::set<std::string> LinkerArgs::GetSearchPathsForProject(const std::set<std::s
|
||||
return out;
|
||||
}
|
||||
|
||||
bool LinkerArgs::ParseArgs(const int argc, const char** argv)
|
||||
bool LinkerArgs::ParseArgs(const int argc, const char** argv, bool& shouldContinue)
|
||||
{
|
||||
shouldContinue = true;
|
||||
if (!m_argument_parser.ParseArguments(argc - 1, &argv[1]))
|
||||
{
|
||||
PrintUsage();
|
||||
@ -213,6 +228,14 @@ bool LinkerArgs::ParseArgs(const int argc, const char** argv)
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if the user wants to see the version
|
||||
if (m_argument_parser.IsOptionSpecified(OPTION_VERSION))
|
||||
{
|
||||
PrintVersion();
|
||||
shouldContinue = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
m_project_specifiers_to_build = m_argument_parser.GetArguments();
|
||||
if (m_project_specifiers_to_build.empty())
|
||||
{
|
||||
|
@ -31,6 +31,7 @@ private:
|
||||
* \brief Prints a command line usage help text for the Linker tool to stdout.
|
||||
*/
|
||||
static void PrintUsage();
|
||||
static void PrintVersion();
|
||||
|
||||
void SetVerbose(bool isVerbose);
|
||||
|
||||
@ -56,7 +57,7 @@ public:
|
||||
bool m_verbose;
|
||||
|
||||
LinkerArgs();
|
||||
bool ParseArgs(int argc, const char** argv);
|
||||
bool ParseArgs(int argc, const char** argv, bool& shouldContinue);
|
||||
|
||||
/**
|
||||
* \brief Converts the output path specified by command line arguments to a path applies for the specified project.
|
||||
|
Reference in New Issue
Block a user