mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-04 13:42:55 +01:00
refactor console error output
This commit is contained in:
@@ -350,7 +350,7 @@ namespace CommandLine
|
||||
}
|
||||
else if (!firstOption)
|
||||
{
|
||||
Console::WriteLineError("All options must be passed at the end of the command line.");
|
||||
Console::Error::WriteLine("All options must be passed at the end of the command line.");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
@@ -383,8 +383,8 @@ namespace CommandLine
|
||||
const CommandLineOptionDefinition * option = FindOption(options, optionName);
|
||||
if (option == nullptr)
|
||||
{
|
||||
Console::WriteError("Unknown option: --");
|
||||
Console::WriteLineError(optionName);
|
||||
Console::Error::Write("Unknown option: --");
|
||||
Console::Error::WriteLine(optionName);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -399,8 +399,8 @@ namespace CommandLine
|
||||
const char * valueString = nullptr;
|
||||
if (!argEnumerator->TryPopString(&valueString))
|
||||
{
|
||||
Console::WriteError("Expected value for option: ");
|
||||
Console::WriteLineError(optionName);
|
||||
Console::Error::Write("Expected value for option: ");
|
||||
Console::Error::WriteLine(optionName);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -414,8 +414,8 @@ namespace CommandLine
|
||||
{
|
||||
if (option->Type == CMDLINE_TYPE_SWITCH)
|
||||
{
|
||||
Console::WriteError("Option is a switch: ");
|
||||
Console::WriteLineError(optionName);
|
||||
Console::Error::Write("Option is a switch: ");
|
||||
Console::Error::WriteLine(optionName);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
@@ -442,9 +442,9 @@ namespace CommandLine
|
||||
option = FindOption(options, shortOption[0]);
|
||||
if (option == nullptr)
|
||||
{
|
||||
Console::WriteError("Unknown option: -");
|
||||
Console::WriteError(shortOption[0]);
|
||||
Console::WriteLineError();
|
||||
Console::Error::Write("Unknown option: -");
|
||||
Console::Error::Write(shortOption[0]);
|
||||
Console::Error::WriteLine();
|
||||
return false;
|
||||
}
|
||||
if (option->Type == CMDLINE_TYPE_SWITCH)
|
||||
@@ -469,9 +469,9 @@ namespace CommandLine
|
||||
const char * valueString = nullptr;
|
||||
if (!argEnumerator->TryPopString(&valueString))
|
||||
{
|
||||
Console::WriteError("Expected value for option: ");
|
||||
Console::WriteError(option->ShortName);
|
||||
Console::WriteLineError();
|
||||
Console::Error::Write("Expected value for option: ");
|
||||
Console::Error::Write(option->ShortName);
|
||||
Console::Error::WriteLine();
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -502,8 +502,8 @@ namespace CommandLine
|
||||
*((utf8 * *)option->OutAddress) = String::Duplicate(valueString);
|
||||
return true;
|
||||
default:
|
||||
Console::WriteError("Unknown CMDLINE_TYPE for: ");
|
||||
Console::WriteLineError(option->LongName);
|
||||
Console::Error::Write("Unknown CMDLINE_TYPE for: ");
|
||||
Console::Error::WriteLine(option->LongName);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,7 +163,7 @@ exitcode_t HandleCommandEdit(CommandLineArgEnumerator * enumerator)
|
||||
const char * parkUri;
|
||||
if (!enumerator->TryPopString(&parkUri))
|
||||
{
|
||||
Console::WriteLineError("Expected path or URL to a saved park.");
|
||||
Console::Error::WriteLine("Expected path or URL to a saved park.");
|
||||
return EXITCODE_FAIL;
|
||||
}
|
||||
String::Set(gOpenRCT2StartupActionPath, sizeof(gOpenRCT2StartupActionPath), parkUri);
|
||||
@@ -197,7 +197,7 @@ exitcode_t HandleCommandHost(CommandLineArgEnumerator * enumerator)
|
||||
const char * parkUri;
|
||||
if (!enumerator->TryPopString(&parkUri))
|
||||
{
|
||||
Console::WriteLineError("Expected path or URL to a saved park.");
|
||||
Console::Error::WriteLine("Expected path or URL to a saved park.");
|
||||
return EXITCODE_FAIL;
|
||||
}
|
||||
|
||||
@@ -220,7 +220,7 @@ exitcode_t HandleCommandJoin(CommandLineArgEnumerator * enumerator)
|
||||
const char * hostname;
|
||||
if (!enumerator->TryPopString(&hostname))
|
||||
{
|
||||
Console::WriteLineError("Expected a hostname or IP address to the server to connect to.");
|
||||
Console::Error::WriteLine("Expected a hostname or IP address to the server to connect to.");
|
||||
return EXITCODE_FAIL;
|
||||
}
|
||||
|
||||
|
||||
@@ -44,24 +44,36 @@ namespace Console
|
||||
puts(str);
|
||||
}
|
||||
|
||||
void WriteError(char c)
|
||||
namespace Error
|
||||
{
|
||||
fputc(c, stderr);
|
||||
}
|
||||
void Write(char c)
|
||||
{
|
||||
fputc(c, stderr);
|
||||
}
|
||||
|
||||
void WriteError(const utf8 * str)
|
||||
{
|
||||
fputs(str, stderr);
|
||||
}
|
||||
void Write(const utf8 * str)
|
||||
{
|
||||
fputs(str, stderr);
|
||||
}
|
||||
|
||||
void WriteLineError()
|
||||
{
|
||||
fputs(platform_get_new_line(), stderr);
|
||||
}
|
||||
void WriteFormat(const utf8 * format, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
void WriteLineError(const utf8 * str)
|
||||
{
|
||||
fputs(str, stderr);
|
||||
WriteLineError();
|
||||
va_start(args, format);
|
||||
vfprintf(stderr, format, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void WriteLine()
|
||||
{
|
||||
fputs(platform_get_new_line(), stderr);
|
||||
}
|
||||
|
||||
void WriteLine(const utf8 * str)
|
||||
{
|
||||
fputs(str, stderr);
|
||||
WriteLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,8 +13,13 @@ namespace Console
|
||||
void WriteFormat(const utf8 * format, ...);
|
||||
void WriteLine();
|
||||
void WriteLine(const utf8 * str);
|
||||
void WriteError(char c);
|
||||
void WriteError(const utf8 * str);
|
||||
void WriteLineError();
|
||||
void WriteLineError(const utf8 * str);
|
||||
|
||||
namespace Error
|
||||
{
|
||||
void Write(char c);
|
||||
void Write(const utf8 * str);
|
||||
void WriteFormat(const utf8 * format, ...);
|
||||
void WriteLine();
|
||||
void WriteLine(const utf8 * str);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user