Skip to content

Commit

Permalink
chore: formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
zaucy committed Aug 7, 2024
1 parent 61b4924 commit 167c26d
Showing 1 changed file with 77 additions and 74 deletions.
151 changes: 77 additions & 74 deletions Source/EcsactEditor/Private/EcsactEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,86 +291,89 @@ auto FEcsactEditorModule::OnReceiveEcsactCliJsonMessage(FString Json) -> void {
auto json_object = TSharedPtr<FJsonObject>{};
auto reader = TJsonReaderFactory<>::Create(Json);

if(FJsonSerializer::Deserialize(reader, json_object) &&
json_object.IsValid()) {
auto message_type = json_object->GetStringField(TEXT("type"));

if(message_type == "info") {
UE_LOG(
EcsactEditor,
Log,
TEXT("%s"),
*json_object->GetStringField(TEXT("content"))
);
} else if(message_type == "error") {
UE_LOG(
EcsactEditor,
Error,
TEXT("%s"),
*json_object->GetStringField(TEXT("content"))
);
} else if(message_type == "warning") {
UE_LOG(
EcsactEditor,
Warning,
TEXT("%s"),
*json_object->GetStringField(TEXT("content"))
);
} else if(message_type == "subcommand_start") {
UE_LOG(
EcsactEditor,
Log,
TEXT("subcommand(%i): %s"),
json_object->GetIntegerField(TEXT("id")),
*json_object->GetStringField(TEXT("executable"))
);
} else if(message_type == "subcommand_end") {
UE_LOG(
EcsactEditor,
Log,
TEXT("subcommand(%i): exit code %i"),
json_object->GetIntegerField(TEXT("id")),
json_object->GetIntegerField(TEXT("exit_code"))
);
} else if(message_type == "subcommand_stdout") {
UE_LOG(
EcsactEditor,
Log,
TEXT("subcommand(%i): %s"),
json_object->GetIntegerField(TEXT("id")),
*json_object->GetStringField(TEXT("line"))
);
} else if(message_type == "subcommand_stderr") {
UE_LOG(
EcsactEditor,
Error,
TEXT("subcommand(%i): %s"),
json_object->GetIntegerField(TEXT("id")),
*json_object->GetStringField(TEXT("line"))
);
} else if(message_type == "success") {
UE_LOG(
EcsactEditor,
Log,
TEXT("%s"),
*json_object->GetStringField(TEXT("content"))
);
} else {
UE_LOG(
EcsactEditor,
Warning,
TEXT("Unhandled Message (%s): %s"),
*message_type,
*Json
);
}
} else {
if(!FJsonSerializer::Deserialize(reader, json_object)) {
UE_LOG(
EcsactEditor,
Error,
TEXT("Failed to parse JSON message: %s"),
*Json
);
return;
}
if(!json_object.IsValid()) {
return;
}

auto message_type = json_object->GetStringField(TEXT("type"));

if(message_type == "info") {
UE_LOG(
EcsactEditor,
Log,
TEXT("%s"),
*json_object->GetStringField(TEXT("content"))
);
} else if(message_type == "error") {
UE_LOG(
EcsactEditor,
Error,
TEXT("%s"),
*json_object->GetStringField(TEXT("content"))
);
} else if(message_type == "warning") {
UE_LOG(
EcsactEditor,
Warning,
TEXT("%s"),
*json_object->GetStringField(TEXT("content"))
);
} else if(message_type == "subcommand_start") {
UE_LOG(
EcsactEditor,
Log,
TEXT("subcommand(%i): %s"),
json_object->GetIntegerField(TEXT("id")),
*json_object->GetStringField(TEXT("executable"))
);
} else if(message_type == "subcommand_end") {
UE_LOG(
EcsactEditor,
Log,
TEXT("subcommand(%i): exit code %i"),
json_object->GetIntegerField(TEXT("id")),
json_object->GetIntegerField(TEXT("exit_code"))
);
} else if(message_type == "subcommand_stdout") {
UE_LOG(
EcsactEditor,
Log,
TEXT("subcommand(%i): %s"),
json_object->GetIntegerField(TEXT("id")),
*json_object->GetStringField(TEXT("line"))
);
} else if(message_type == "subcommand_stderr") {
UE_LOG(
EcsactEditor,
Error,
TEXT("subcommand(%i): %s"),
json_object->GetIntegerField(TEXT("id")),
*json_object->GetStringField(TEXT("line"))
);
} else if(message_type == "success") {
UE_LOG(
EcsactEditor,
Log,
TEXT("%s"),
*json_object->GetStringField(TEXT("content"))
);
} else {
UE_LOG(
EcsactEditor,
Warning,
TEXT("Unhandled Message (%s): %s"),
*message_type,
*Json
);
}
}

Expand Down

0 comments on commit 167c26d

Please sign in to comment.