chore: use filename of argv0 in UsageInformation

This commit is contained in:
Jan 2024-09-23 23:05:04 +02:00
parent 32480a75eb
commit 5fee875495
No known key found for this signature in database
GPG Key ID: 44B581F78FF5C57C
10 changed files with 22 additions and 12 deletions

View File

@ -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)
{

View File

@ -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);

View File

@ -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)
{

View File

@ -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:

View File

@ -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)
{

View File

@ -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);

View File

@ -2,11 +2,14 @@
#include "Utils/StringUtils.h"
#include <filesystem>
#include <format>
#include <iostream>
#include <sstream>
#include <string>
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();
}

View File

@ -19,6 +19,8 @@ public:
std::string GetValueForOption(const CommandLineOption* option) const;
std::vector<std::string> GetParametersForOption(const CommandLineOption* option) const;
[[nodiscard]] std::string GetExecutableName() const;
private:
std::vector<const CommandLineOption*> m_command_line_options;
std::map<const CommandLineOption*, std::vector<std::string>> m_matched_options;

View File

@ -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)
{

View File

@ -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: