adamrehn / ue4cli

Command-line interface for Unreal Engine 4
https://docs.adamrehn.com/ue4cli/
MIT License
249 stars 45 forks source link

`ue4 run` command-line cannot pass a level URL due to parameter ordering #32

Closed TBBle closed 3 years ago

TBBle commented 3 years ago

Trying to work out why

ue4 run Highrise?Bots=8 -server -nosteam

doesn't pass Bots through to the started server, I realised that the command being generated was

D:\Unreal\UnrealEngine\Engine\Binaries\Win64\UE4Editor-Cmd.exe D:\Unreal\ShooterGame\ShooterGame.uproject -stdout -FullStdOutLogOutput Highrise?Bots=8 -server -nosteam

but UE4 (4.24 here) isn't parsing the URL that late in the CLI, so it needs to be

D:\Unreal\UnrealEngine\Engine\Binaries\Win64\UE4Editor-Cmd.exe D:\Unreal\ShooterGame\ShooterGame.uproject Highrise?Bots=8 -server -nosteam -stdout -FullStdOutLogOutput

i.e. in UnrealManagerBase.runEditor, extraFlags needs to be interpolated immediately after projectFile, not at the end. The below seems to work in my testing:

Utility.run([self.getEditorBinary(True), projectFile, *extraFlags, '-stdout', '-FullStdOutLogOutput'], raiseOnError=True)
adamrehn commented 3 years ago

That's a rather bizarre (and brittle) parsing behaviour that UE4 is exhibiting there. Oh well, at least we know how to work around it.

TBBle commented 3 years ago

"Brittle" is a kind term to use for UE4's command-line parsing setup.