From fd421c47841e3bc7f4623ce4d2c89c983b9c871e Mon Sep 17 00:00:00 2001 From: Jan Date: Sun, 20 Oct 2024 16:23:42 +0200 Subject: [PATCH] chore: use std format for linker and unlinker args --- src/Linker/LinkerArgs.cpp | 8 ++++---- src/Unlinker/UnlinkerArgs.cpp | 11 +++++------ src/Unlinker/UnlinkerArgs.h | 4 ++-- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/Linker/LinkerArgs.cpp b/src/Linker/LinkerArgs.cpp index b7ca5f4e..323fd156 100644 --- a/src/Linker/LinkerArgs.cpp +++ b/src/Linker/LinkerArgs.cpp @@ -46,7 +46,7 @@ const CommandLineOption* const OPTION_BASE_FOLDER = const CommandLineOption* const OPTION_OUTPUT_FOLDER = CommandLineOption::Builder::Create() .WithLongName("output-folder") - .WithDescription("Specifies the output folder containing the build artifacts. Defaults to \"" + std::string(LinkerArgs::DEFAULT_OUTPUT_FOLDER) + "\".") + .WithDescription(std::format("Specifies the output folder containing the build artifacts. Defaults to \"{}\".", LinkerArgs::DEFAULT_OUTPUT_FOLDER)) .WithParameter("outputFolderPath") .Build(); @@ -61,14 +61,14 @@ const CommandLineOption* const OPTION_ADD_ASSET_SEARCH_PATH = const CommandLineOption* const OPTION_ASSET_SEARCH_PATH = CommandLineOption::Builder::Create() .WithLongName("asset-search-path") - .WithDescription("Specifies the search paths used for assets. Defaults to \"" + std::string(LinkerArgs::DEFAULT_ASSET_SEARCH_PATH) + "\".") + .WithDescription(std::format("Specifies the search paths used for assets. Defaults to \"{}\".", LinkerArgs::DEFAULT_ASSET_SEARCH_PATH)) .WithParameter("assetSearchPathString") .Build(); const CommandLineOption* const OPTION_GDT_SEARCH_PATH = CommandLineOption::Builder::Create() .WithLongName("gdt-search-path") - .WithDescription("Specifies the search paths used for gdt files. Defaults to \"" + std::string(LinkerArgs::DEFAULT_GDT_SEARCH_PATH) + "\".") + .WithDescription(std::format("Specifies the search paths used for gdt files. Defaults to \"{}\".", LinkerArgs::DEFAULT_GDT_SEARCH_PATH)) .WithParameter("gdtSearchPathString") .Build(); @@ -83,7 +83,7 @@ const CommandLineOption* const OPTION_ADD_SOURCE_SEARCH_PATH = const CommandLineOption* const OPTION_SOURCE_SEARCH_PATH = CommandLineOption::Builder::Create() .WithLongName("source-search-path") - .WithDescription("Specifies the search paths used for source files. Defaults to \"" + std::string(LinkerArgs::DEFAULT_SOURCE_SEARCH_PATH) + "\".") + .WithDescription(std::format("Specifies the search paths used for source files. Defaults to \"{}\".", LinkerArgs::DEFAULT_SOURCE_SEARCH_PATH)) .WithParameter("sourceSearchPathString") .Build(); diff --git a/src/Unlinker/UnlinkerArgs.cpp b/src/Unlinker/UnlinkerArgs.cpp index aa2102e6..3d492667 100644 --- a/src/Unlinker/UnlinkerArgs.cpp +++ b/src/Unlinker/UnlinkerArgs.cpp @@ -59,8 +59,7 @@ const CommandLineOption* const OPTION_OUTPUT_FOLDER = CommandLineOption::Builder::Create() .WithShortName("o") .WithLongName("output-folder") - .WithDescription("Specifies the output folder containing the contents of the unlinked zones. Defaults to \"" - + std::string(UnlinkerArgs::DEFAULT_OUTPUT_FOLDER) + "\"") + .WithDescription(std::format("Specifies the output folder containing the contents of the unlinked zones. Defaults to \"{}\"", UnlinkerArgs::DEFAULT_OUTPUT_FOLDER)) .WithParameter("outputFolderPath") .Build(); @@ -178,7 +177,7 @@ void UnlinkerArgs::SetVerbose(const bool isVerbose) ObjWriting::Configuration.Verbose = isVerbose; } -bool UnlinkerArgs::SetImageDumpingMode() +bool UnlinkerArgs::SetImageDumpingMode() const { auto specifiedValue = m_argument_parser.GetValueForOption(OPTION_IMAGE_FORMAT); utils::MakeStringLowerCase(specifiedValue); @@ -196,11 +195,11 @@ bool UnlinkerArgs::SetImageDumpingMode() } const std::string originalValue = m_argument_parser.GetValueForOption(OPTION_IMAGE_FORMAT); - printf("Illegal value: \"%s\" is not a valid image output format. Use -? to see usage information.\n", originalValue.c_str()); + std::cerr << std::format("Illegal value: \"{}\" is not a valid image output format. Use -? to see usage information.\n", originalValue); return false; } -bool UnlinkerArgs::SetModelDumpingMode() +bool UnlinkerArgs::SetModelDumpingMode() const { auto specifiedValue = m_argument_parser.GetValueForOption(OPTION_MODEL_FORMAT); utils::MakeStringLowerCase(specifiedValue); @@ -230,7 +229,7 @@ bool UnlinkerArgs::SetModelDumpingMode() } const std::string originalValue = m_argument_parser.GetValueForOption(OPTION_MODEL_FORMAT); - printf("Illegal value: \"%s\" is not a valid model output format. Use -? to see usage information.\n", originalValue.c_str()); + std::cerr << std::format("Illegal value: \"{}\" is not a valid model output format. Use -? to see usage information.\n", originalValue); return false; } diff --git a/src/Unlinker/UnlinkerArgs.h b/src/Unlinker/UnlinkerArgs.h index fea432b8..f9e61de2 100644 --- a/src/Unlinker/UnlinkerArgs.h +++ b/src/Unlinker/UnlinkerArgs.h @@ -24,8 +24,8 @@ private: static void PrintVersion(); void SetVerbose(bool isVerbose); - bool SetImageDumpingMode(); - bool SetModelDumpingMode(); + bool SetImageDumpingMode() const; + bool SetModelDumpingMode() const; void AddSpecifiedAssetType(std::string value); void ParseCommaSeparatedAssetTypeString(const std::string& input);