Close #19176, close #19273: Consistent “CmdLine” naming

This commit is contained in:
Gymnasiast 2023-02-23 00:03:30 +01:00
parent d5b7569537
commit fd4c9a7b9d
No known key found for this signature in database
GPG Key ID: DBFFF47AB2CA3EDD
23 changed files with 50 additions and 49 deletions

View File

@ -9,7 +9,7 @@
#include <openrct2/Context.h>
#include <openrct2/OpenRCT2.h>
#include <openrct2/cmdline/CommandLine.hpp>
#include <openrct2/command_line/CommandLine.hpp>
#include <openrct2/platform/Platform.h>
using namespace OpenRCT2;
@ -20,7 +20,7 @@ using namespace OpenRCT2;
int main(int argc, const char** argv)
{
int32_t rc = EXIT_SUCCESS;
int runGame = CmdlineRun(argv, argc);
int runGame = CommandLineRun(argv, argc);
Platform::CoreInit();
if (runGame == EXITCODE_CONTINUE)
{

View File

@ -19,7 +19,7 @@
#include <openrct2/OpenRCT2.h>
#include <openrct2/PlatformEnvironment.h>
#include <openrct2/audio/AudioContext.h>
#include <openrct2/cmdline/CommandLine.hpp>
#include <openrct2/command_line/CommandLine.hpp>
#include <openrct2/platform/Platform.h>
#include <openrct2/ui/UiContext.h>
@ -43,7 +43,7 @@ int main(int argc, const char** argv)
{
std::unique_ptr<IContext> context;
int32_t rc = EXIT_SUCCESS;
int runGame = CmdlineRun(argv, argc);
int runGame = CommandLineRun(argv, argc);
Platform::CoreInit();
RegisterBitmapReader();
if (runGame == EXITCODE_CONTINUE)

View File

@ -7,7 +7,7 @@
* OpenRCT2 is licensed under the GNU General Public License version 3.
*****************************************************************************/
#include "CmdlineSprite.h"
#include "CommandLineSprite.h"
#include "Context.h"
#include "OpenRCT2.h"
@ -33,7 +33,7 @@
using namespace OpenRCT2::Drawing;
static int32_t CmdLineForSpriteCombine(const char** argv, int32_t argc);
static int32_t CommandLineForSpriteCombine(const char** argv, int32_t argc);
class SpriteFile
{
@ -265,7 +265,7 @@ static std::string PopStr(std::ostringstream& oss)
return str;
}
int32_t CmdLineForSprite(const char** argv, int32_t argc)
int32_t CommandLineForSprite(const char** argv, int32_t argc)
{
gOpenRCT2Headless = true;
if (argc == 0)
@ -615,14 +615,14 @@ int32_t CmdLineForSprite(const char** argv, int32_t argc)
if (_strcmpi(argv[0], "combine") == 0)
{
return CmdLineForSpriteCombine(argv, argc);
return CommandLineForSpriteCombine(argv, argc);
}
fprintf(stderr, "Unknown sprite command.\n");
return 1;
}
static int32_t CmdLineForSpriteCombine(const char** argv, int32_t argc)
static int32_t CommandLineForSpriteCombine(const char** argv, int32_t argc)
{
if (argc < 4)
{

View File

@ -12,5 +12,5 @@
#include "common.h"
#include "drawing/ImageImporter.h"
int32_t CmdLineForSprite(const char** argv, int32_t argc);
int32_t CommandLineForSprite(const char** argv, int32_t argc);
extern OpenRCT2::Drawing::ImageImporter::ImportMode gSpriteMode;

View File

@ -65,4 +65,4 @@ extern PromptMode gSavePromptMode;
void OpenRCT2WriteFullVersionInfo(utf8* buffer, size_t bufferSize);
void OpenRCT2Finish();
int32_t CmdlineRun(const char** argv, int32_t argc);
int32_t CommandLineRun(const char** argv, int32_t argc);

View File

@ -21,7 +21,7 @@ static exitcode_t HandleBenchGfx(CommandLineArgEnumerator* argEnumerator)
{
const char** argv = const_cast<const char**>(argEnumerator->GetArguments()) + argEnumerator->GetIndex();
int32_t argc = argEnumerator->GetCount() - argEnumerator->GetIndex();
int32_t result = CmdlineForGfxbench(argv, argc);
int32_t result = CommandLineForGfxbench(argv, argc);
if (result < 0)
{
return EXITCODE_FAIL;

View File

@ -153,7 +153,7 @@ static void BM_paint_session_arrange(benchmark::State& state, const std::vector<
delete[] local_s;
}
static int cmdline_for_bench_sprite_sort(int argc, const char** argv)
static int command_line_for_bench_sprite_sort(int argc, const char** argv)
{
{
// Register some basic "baseline" benchmark
@ -204,7 +204,7 @@ static exitcode_t HandleBenchSpriteSort(CommandLineArgEnumerator* argEnumerator)
{
const char** argv = const_cast<const char**>(argEnumerator->GetArguments()) + argEnumerator->GetIndex();
int32_t argc = argEnumerator->GetCount() - argEnumerator->GetIndex();
int32_t result = cmdline_for_bench_sprite_sort(argc, argv);
int32_t result = command_line_for_bench_sprite_sort(argc, argv);
if (result < 0)
{
return EXITCODE_FAIL;

View File

@ -87,7 +87,7 @@ static void BM_update(benchmark::State& state, const std::string& filename)
}
}
static int CmdlineForBenchSpriteSort(int argc, const char* const* argv)
static int CommandLineForBenchSpriteSort(int argc, const char* const* argv)
{
// Add a baseline test on an empty park
benchmark::RegisterBenchmark("baseline", BM_update, std::string{});
@ -129,7 +129,7 @@ static exitcode_t HandleBenchUpdate(CommandLineArgEnumerator* argEnumerator)
{
const char* const* argv = static_cast<const char* const*>(argEnumerator->GetArguments()) + argEnumerator->GetIndex();
int32_t argc = argEnumerator->GetCount() - argEnumerator->GetIndex();
int32_t result = CmdlineForBenchSpriteSort(argc, argv);
int32_t result = CommandLineForBenchSpriteSort(argc, argv);
if (result < 0)
{
return EXITCODE_FAIL;

View File

@ -524,7 +524,7 @@ namespace CommandLine
}
} // namespace CommandLine
int32_t CmdlineRun(const char** argv, int32_t argc)
int32_t CommandLineRun(const char** argv, int32_t argc)
{
auto argEnumerator = CommandLineArgEnumerator(argv, argc);

View File

@ -43,7 +43,7 @@ static exitcode_t HandleScreenshot(CommandLineArgEnumerator* argEnumerator)
{
const char** argv = const_cast<const char**>(argEnumerator->GetArguments()) + argEnumerator->GetIndex();
int32_t argc = argEnumerator->GetCount() - argEnumerator->GetIndex();
int32_t result = CmdlineForScreenshot(argv, argc, &_options);
int32_t result = CommandLineForScreenshot(argv, argc, &_options);
if (result < 0)
{
return EXITCODE_FAIL;

View File

@ -7,7 +7,7 @@
* OpenRCT2 is licensed under the GNU General Public License version 3.
*****************************************************************************/
#include "../CmdlineSprite.h"
#include "../CommandLineSprite.h"
#include "../core/Memory.hpp"
#include "../core/String.hpp"
#include "CommandLine.hpp"
@ -57,7 +57,7 @@ static exitcode_t HandleSprite(CommandLineArgEnumerator* argEnumerator)
const char** argv = const_cast<const char**>(argEnumerator->GetArguments()) + argEnumerator->GetIndex() - 1;
int32_t argc = argEnumerator->GetCount() - argEnumerator->GetIndex() + 1;
int32_t result = CmdLineForSprite(argv, argc);
int32_t result = CommandLineForSprite(argv, argc);
if (result < 0)
{
return EXITCODE_FAIL;

View File

@ -482,7 +482,7 @@ static void BenchgfxRenderScreenshots(const char* inputPath, std::unique_ptr<ICo
ReleaseDPI(dpi);
}
int32_t CmdlineForGfxbench(const char** argv, int32_t argc)
int32_t CommandLineForGfxbench(const char** argv, int32_t argc)
{
if (argc != 1 && argc != 2)
{
@ -562,7 +562,7 @@ static void ApplyOptions(const ScreenshotOptions* options, Viewport& viewport)
}
}
int32_t CmdlineForScreenshot(const char** argv, int32_t argc, ScreenshotOptions* options)
int32_t CommandLineForScreenshot(const char** argv, int32_t argc, ScreenshotOptions* options)
{
// Don't include options in the count (they have been handled by CommandLine::ParseOptions already)
for (int32_t i = 0; i < argc; i++)

View File

@ -58,7 +58,7 @@ std::string ScreenshotDumpPNG(DrawPixelInfo* dpi);
std::string ScreenshotDumpPNG32bpp(int32_t width, int32_t height, const void* pixels);
void ScreenshotGiant();
int32_t CmdlineForScreenshot(const char** argv, int32_t argc, ScreenshotOptions* options);
int32_t CmdlineForGfxbench(const char** argv, int32_t argc);
int32_t CommandLineForScreenshot(const char** argv, int32_t argc, ScreenshotOptions* options);
int32_t CommandLineForGfxbench(const char** argv, int32_t argc);
void CaptureImage(const CaptureOptions& options);

View File

@ -154,8 +154,8 @@
<ClInclude Include="audio\AudioMixer.h" />
<ClInclude Include="audio\AudioSource.h" />
<ClInclude Include="Cheats.h" />
<ClInclude Include="CmdlineSprite.h" />
<ClInclude Include="cmdline\CommandLine.hpp" />
<ClInclude Include="CommandLineSprite.h" />
<ClInclude Include="command_line\CommandLine.hpp" />
<ClInclude Include="common.h" />
<ClInclude Include="config\Config.h" />
<ClInclude Include="config\ConfigEnum.hpp" />
@ -667,18 +667,18 @@
<ClCompile Include="audio\Audio.cpp" />
<ClCompile Include="audio\DummyAudioContext.cpp" />
<ClCompile Include="Cheats.cpp" />
<ClCompile Include="CmdlineSprite.cpp" />
<ClCompile Include="cmdline\BenchGfxCommmands.cpp" />
<ClCompile Include="cmdline\BenchSpriteSort.cpp" />
<ClCompile Include="cmdline/BenchUpdate.cpp" />
<ClCompile Include="cmdline\CommandLine.cpp" />
<ClCompile Include="cmdline\ConvertCommand.cpp" />
<ClCompile Include="cmdline\ParkInfoCommands.cpp" />
<ClCompile Include="cmdline\RootCommands.cpp" />
<ClCompile Include="cmdline\ScreenshotCommands.cpp" />
<ClCompile Include="cmdline\SimulateCommands.cpp" />
<ClCompile Include="cmdline\SpriteCommands.cpp" />
<ClCompile Include="cmdline\UriHandler.cpp" />
<ClCompile Include="CommandLineSprite.cpp" />
<ClCompile Include="command_line\BenchGfxCommmands.cpp" />
<ClCompile Include="command_line\BenchSpriteSort.cpp" />
<ClCompile Include="command_line/BenchUpdate.cpp" />
<ClCompile Include="command_line\CommandLine.cpp" />
<ClCompile Include="command_line\ConvertCommand.cpp" />
<ClCompile Include="command_line\ParkInfoCommands.cpp" />
<ClCompile Include="command_line\RootCommands.cpp" />
<ClCompile Include="command_line\ScreenshotCommands.cpp" />
<ClCompile Include="command_line\SimulateCommands.cpp" />
<ClCompile Include="command_line\SpriteCommands.cpp" />
<ClCompile Include="command_line\UriHandler.cpp" />
<ClCompile Include="config\Config.cpp" />
<ClCompile Include="config\IniReader.cpp" />
<ClCompile Include="config\IniWriter.cpp" />
@ -1028,4 +1028,4 @@
</ClCompile>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
</Project>
</Project>

View File

@ -161,5 +161,6 @@ public:
// This function cannot be marked as 'static', even though it may seem to be,
// as it requires external linkage, which 'static' prevents
__declspec(dllexport) int32_t StartOpenRCT2(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int32_t nCmdShow);
__declspec(dllexport) int32_t
StartOpenRCT2(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCommandLine, int32_t nCmdShow);
#endif // _WIN32

View File

@ -8,7 +8,7 @@
Contains files for mixing and playing music and sound.
- **cmdline**
- **command_line**
Code specific to command line (arguments).

View File

@ -5,7 +5,7 @@
#include <fstream>
#include <gtest/gtest.h>
#include <iterator>
#include <openrct2/CmdlineSprite.h>
#include <openrct2/CommandLineSprite.h>
#include <openrct2/core/Path.hpp>
class CommandLineTests : public testing::Test
@ -54,43 +54,43 @@ public:
}
};
TEST_F(CommandLineTests, cmdline_cmdline_for_sprite_details)
TEST_F(CommandLineTests, command_line_for_sprite_details)
{
std::string exampleFilePath = ExampleSpriteFilePath();
const char* detailsCmd[3] = { "details", exampleFilePath.c_str() };
int32_t result = CmdLineForSprite(detailsCmd, 2);
int32_t result = CommandLineForSprite(detailsCmd, 2);
// need to come up with some way to extract stdout/stderr stream if we want to
// fully test this module
ASSERT_EQ(result, 1);
}
TEST_F(CommandLineTests, cmdline_cmdline_for_sprite_build)
TEST_F(CommandLineTests, command_line_for_sprite_build)
{
std::string manifestFilePath = ManifestFilePath();
std::string outputfilePath = BuildOutputfilePath();
const char* detailsCmd[3] = { "build", outputfilePath.c_str(), manifestFilePath.c_str() };
int32_t result = CmdLineForSprite(detailsCmd, 3);
int32_t result = CommandLineForSprite(detailsCmd, 3);
ASSERT_EQ(result, 1);
// compare the resulting output file and assert its identical to expected
ASSERT_TRUE(CompareSpriteFiles(ExampleSpriteFilePath(), outputfilePath));
}
TEST_F(CommandLineTests, cmdline_cmdline_for_sprite_failed_build)
TEST_F(CommandLineTests, command_line_for_sprite_failed_build)
{
// run on correct manifest file
std::string manifestFilePath = ManifestFilePath();
std::string outputfilePath = BuildOutputfilePath();
const char* detailsCmd[3] = { "build", outputfilePath.c_str(), manifestFilePath.c_str() };
int32_t result = CmdLineForSprite(detailsCmd, 3);
int32_t result = CommandLineForSprite(detailsCmd, 3);
ASSERT_EQ(result, 1);
ASSERT_TRUE(CompareSpriteFiles(ExampleSpriteFilePath(), outputfilePath));
// now use bad manifest and make sure output file is not edited
std::string badManifestFilePath = BadManifestFilePath();
detailsCmd[2] = badManifestFilePath.c_str();
result = CmdLineForSprite(detailsCmd, 3);
result = CommandLineForSprite(detailsCmd, 3);
// check the command failed
ASSERT_EQ(result, -1);
// validate the target file was unchanged