Get Command Line args in UE5

Hi,
I am trying to use command line to get options from it. So, for this, I have instantiated the GameModeBase class and re-defined InitGame in there as following:

void AMyGameModeBase::InitGame(const FString& MapName, const FString& Options, FString& ErrorMessage)
{
    FString file_path;
    if (FParse::Value(FCommandLine::Get(), TEXT("file="), file_path))
    {
        UE_LOG(LogGameMode, Warning, TEXT("File path detected and it is %s"), *file_path);
    }
    else
    {
        UE_LOG(LogGameMode, Warning, TEXT("File path not detected!"));
    }
    Super::InitGame(MapName, Options, ErrorMessage);
}

When I launched the executable as following:

myExe.sh MapName -file=myfile.txt (I am on Linux)

I do not see anything on the log.

I did it with Blueprint also, I have created a GameModeBase Blueprint and I tried to capture the Command line like so:
image

But still cannot see anything on the log when starting the executable.

Any help on that?

Well… the first thing that comes in mind: have you set your gamemode for current level you trying to test it with? it’s in World Settings, the field GameMode Override, like this:
изображение
(or as a default gamemode for the whole project, which i don’t remember where is)

Thanks for that! Unfortunately, I did it but nothing changed, I am still not seeing anything on the log. I was wondering if I need to connect the input of Get Command Line node?

Well, i thought it was an example of attempt, not actual code. If it is, then you surely call than print somewhere. For example on BeginPlay()

Nevertheless, the c++'s version of code should work as is, if you set it as the current gamemode

yep it is working fine now, I just connect it to Event InitializeHUDFor Player.

Thanks for your help!