diff --git a/src/Linker/LinkerArgs.cpp b/src/Linker/LinkerArgs.cpp index 32d4c186..b7ca5f4e 100644 --- a/src/Linker/LinkerArgs.cpp +++ b/src/Linker/LinkerArgs.cpp @@ -139,9 +139,9 @@ LinkerArgs::LinkerArgs() { } -void LinkerArgs::PrintUsage() +void LinkerArgs::PrintUsage() const { - UsageInformation usage("Linker.exe"); + UsageInformation usage(m_argument_parser.GetExecutableName()); for (const auto* commandLineOption : COMMAND_LINE_OPTIONS) { diff --git a/src/Linker/LinkerArgs.h b/src/Linker/LinkerArgs.h index a36c0d33..41fb32dd 100644 --- a/src/Linker/LinkerArgs.h +++ b/src/Linker/LinkerArgs.h @@ -59,7 +59,7 @@ private: /** * \brief Prints a command line usage help text for the Linker tool to stdout. */ - static void PrintUsage(); + void PrintUsage() const; static void PrintVersion(); void SetBinFolder(const char* argv0); diff --git a/src/RawTemplater/RawTemplaterArguments.cpp b/src/RawTemplater/RawTemplaterArguments.cpp index a5ce4cca..7962e164 100644 --- a/src/RawTemplater/RawTemplaterArguments.cpp +++ b/src/RawTemplater/RawTemplaterArguments.cpp @@ -69,9 +69,9 @@ RawTemplaterArguments::RawTemplaterArguments() { } -void RawTemplaterArguments::PrintUsage() +void RawTemplaterArguments::PrintUsage() const { - UsageInformation usage("RawTemplater.exe"); + UsageInformation usage(m_argument_parser.GetExecutableName()); for (const auto* commandLineOption : COMMAND_LINE_OPTIONS) { diff --git a/src/RawTemplater/RawTemplaterArguments.h b/src/RawTemplater/RawTemplaterArguments.h index dadb1f88..cfaac7b3 100644 --- a/src/RawTemplater/RawTemplaterArguments.h +++ b/src/RawTemplater/RawTemplaterArguments.h @@ -13,7 +13,7 @@ class RawTemplaterArguments /** * \brief Prints a command line usage help text for the RawTemplater tool to stdout. */ - static void PrintUsage(); + void PrintUsage() const; static void PrintVersion(); public: diff --git a/src/Unlinker/UnlinkerArgs.cpp b/src/Unlinker/UnlinkerArgs.cpp index 4b74c27e..ddefb61e 100644 --- a/src/Unlinker/UnlinkerArgs.cpp +++ b/src/Unlinker/UnlinkerArgs.cpp @@ -151,9 +151,9 @@ UnlinkerArgs::UnlinkerArgs() { } -void UnlinkerArgs::PrintUsage() +void UnlinkerArgs::PrintUsage() const { - UsageInformation usage("Unlinker.exe"); + UsageInformation usage(m_argument_parser.GetExecutableName()); for (const auto* commandLineOption : COMMAND_LINE_OPTIONS) { diff --git a/src/Unlinker/UnlinkerArgs.h b/src/Unlinker/UnlinkerArgs.h index 35872566..9e2867e2 100644 --- a/src/Unlinker/UnlinkerArgs.h +++ b/src/Unlinker/UnlinkerArgs.h @@ -20,7 +20,7 @@ private: /** * \brief Prints a command line usage help text for the Unlinker tool to stdout. */ - static void PrintUsage(); + void PrintUsage() const; static void PrintVersion(); void SetVerbose(bool isVerbose); diff --git a/src/Utils/Utils/Arguments/ArgumentParser.cpp b/src/Utils/Utils/Arguments/ArgumentParser.cpp index 135344f5..1f89a5ed 100644 --- a/src/Utils/Utils/Arguments/ArgumentParser.cpp +++ b/src/Utils/Utils/Arguments/ArgumentParser.cpp @@ -2,11 +2,14 @@ #include "Utils/StringUtils.h" +#include #include #include #include #include +namespace fs = std::filesystem; + constexpr auto PREFIX_LONG = "--"; constexpr auto PREFIX_SHORT = "-"; @@ -169,3 +172,8 @@ bool ArgumentParser::IsOptionSpecified(const CommandLineOption* option) const { return m_matched_options.find(option) != m_matched_options.end(); } + +std::string ArgumentParser::GetExecutableName() const +{ + return fs::path(m_path).filename().string(); +} diff --git a/src/Utils/Utils/Arguments/ArgumentParser.h b/src/Utils/Utils/Arguments/ArgumentParser.h index 17071857..c43269f6 100644 --- a/src/Utils/Utils/Arguments/ArgumentParser.h +++ b/src/Utils/Utils/Arguments/ArgumentParser.h @@ -19,6 +19,8 @@ public: std::string GetValueForOption(const CommandLineOption* option) const; std::vector GetParametersForOption(const CommandLineOption* option) const; + [[nodiscard]] std::string GetExecutableName() const; + private: std::vector m_command_line_options; std::map> m_matched_options; diff --git a/src/ZoneCodeGeneratorLib/ZoneCodeGeneratorArguments.cpp b/src/ZoneCodeGeneratorLib/ZoneCodeGeneratorArguments.cpp index e0e9902a..bd19c4fa 100644 --- a/src/ZoneCodeGeneratorLib/ZoneCodeGeneratorArguments.cpp +++ b/src/ZoneCodeGeneratorLib/ZoneCodeGeneratorArguments.cpp @@ -118,9 +118,9 @@ ZoneCodeGeneratorArguments::ZoneCodeGeneratorArguments() m_verbose = false; } -void ZoneCodeGeneratorArguments::PrintUsage() +void ZoneCodeGeneratorArguments::PrintUsage() const { - UsageInformation usage("ZoneCodeGenerator.exe"); + UsageInformation usage(m_argument_parser.GetExecutableName()); for (const auto* commandLineOption : COMMAND_LINE_OPTIONS) { diff --git a/src/ZoneCodeGeneratorLib/ZoneCodeGeneratorArguments.h b/src/ZoneCodeGeneratorLib/ZoneCodeGeneratorArguments.h index 351efc2e..4a9238fe 100644 --- a/src/ZoneCodeGeneratorLib/ZoneCodeGeneratorArguments.h +++ b/src/ZoneCodeGeneratorLib/ZoneCodeGeneratorArguments.h @@ -12,7 +12,7 @@ class ZoneCodeGeneratorArguments /** * \brief Prints a command line usage help text for the Unlinker tool to stdout. */ - static void PrintUsage(); + void PrintUsage() const; static void PrintVersion(); public: