How to load level in commandlet?

Hello I’m just starting unreal!
I want to log all actors in level with commandlet, so I wrote the code like this.

#include "MyCommandlet.h"
#include "Kismet/GameplayStatics.h"
#include "Engine/StaticMeshActor.h"
#include "MyCharacter.h"

int32 UMyCommandlet::Main(const FString& Params)
{
    TArray<AActor*> arrActors;
    UWorld* World = GetWorld();

    if (World)
    {
        UGameplayStatics::GetAllActorsOfClass(GetWorld(), AMyCharacter::StaticClass(), arrActors);

        for (int i = 0; i < arrActors.Num(); i++)
        {
            AMyCharacter* pCharacter = dynamic_cast<AMyCharacter*>(arrActors[i]);

            UE_LOG(LogTemp, Display, TEXT("%d"), pCharacter->TestValue);

        }   
    }

    return 0;
}

But GetWorld() returns NULL. I thouht the reason is that when commandlet is called, there are no levels loaded.

Actually Unreal Engine document says “Commandlets are executed in a “raw” environment, in which the game isn’t loaded, the client code isn’t loaded, no levels are loaded, and no actors exist.” LINK: https://docs.unrealengine.com/4.26/en-US/API/Runtime/Engine/Commandlets/UCommandlet/#:~:text=UCommandlet%20%3A%20public%20UObject-,Remarks,-Commandlet%20

Then how can I load level or getworld() in commandlet…??

Did you try UWorld* World = GEditor->GetEditorWorldContext().World(); ?