UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
Commandlet.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
32#pragma once
33
34#include "CoreMinimal.h"
36#include "UObject/Object.h"
37#include "Commandlet.generated.h"
38
39UCLASS(abstract, transient, MinimalAPI)
41{
43
44
45 UPROPERTY()
46 FString HelpDescription;
47
49 UPROPERTY()
50 FString HelpUsage;
51
53 UPROPERTY()
54 FString HelpWebLink;
55
57 UPROPERTY()
58 TArray<FString> HelpParamNames;
59
61 UPROPERTY()
62 TArray<FString> HelpParamDescriptions;
63
69 UPROPERTY()
70 uint32 IsServer:1;
71
72 UPROPERTY()
73 uint32 IsClient:1;
74
75 UPROPERTY()
76 uint32 IsEditor:1;
77
79 UPROPERTY()
80 uint32 LogToConsole:1;
81
83 UPROPERTY()
84 uint32 ShowErrorCount:1;
85
87 UPROPERTY()
88 uint32 ShowProgress:1;
89
91 UPROPERTY()
92 uint32 FastExit:1;
93
95 UPROPERTY()
96 uint32 UseCommandletResultAsExitCode: 1;
97
103 virtual int32 Main(const FString& Params) { return 0; }
104
115 static void ParseCommandLine( const TCHAR* CmdLine, TArray<FString>& Tokens, TArray<FString>& Switches )
116 {
117 FString NextToken;
118 while ( FParse::Token(CmdLine, NextToken, false) )
119 {
120 if ( **NextToken == TCHAR('-') )
121 {
122 Switches.Add(NextToken.Mid(1));
123 }
124 else
125 {
126 Tokens.Add(MoveTemp(NextToken));
127 }
128 }
129 }
130
142 static void ParseCommandLine( const TCHAR* CmdLine, TArray<FString>& Tokens, TArray<FString>& Switches, TMap<FString, FString>& Params )
143 {
144 // Turn -foo -bar=1 into [Foo, Bar=1]
145 ParseCommandLine(CmdLine, Tokens, Switches);
146
147 for (int32 SwitchIdx = Switches.Num() - 1; SwitchIdx >= 0; --SwitchIdx)
148 {
149 FString& Switch = Switches[SwitchIdx];
151
152 // Remove Bar=1 from the switch list and put it in params as {Bar,1}.
153 // Note: Handle nested equality such as Bar="Key=Value"
155 if (Switch.FindChar(TEXT('='), AssignmentIndex))
156 {
157 Params.Add(Switch.Left(AssignmentIndex), Switch.RightChop(AssignmentIndex+1).TrimQuotes());
158 Switches.RemoveAt(SwitchIdx);
159 }
160 }
161 }
162
163#if WITH_EDITOR
172#endif // WITH_EDITOR
173
179 virtual void CreateCustomEngine(const FString& Params) {}
180};
181
183{
189 ENGINE_API void TickEngine(class UWorld* InWorld = nullptr, double InDeltaTime = 0.0);
190}
#define TEXT(x)
Definition Platform.h:1272
FPlatformTypes::TCHAR TCHAR
Either ANSICHAR or WIDECHAR, depending on whether the platform supports wide characters or the requir...
Definition Platform.h:1135
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define UPROPERTY(...)
UObject definition macros.
Definition ObjectMacros.h:744
#define GENERATED_UCLASS_BODY(...)
Definition ObjectMacros.h:768
#define UCLASS(...)
Definition ObjectMacros.h:776
UE_INTRINSIC_CAST UE_REWRITE constexpr std::remove_reference_t< T > && MoveTemp(T &&Obj) noexcept
Definition UnrealTemplate.h:520
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition Array.h:670
UE_NODEBUG UE_FORCEINLINE_HINT SizeType Add(ElementType &&Item)
Definition Array.h:2696
Definition UnrealString.h.inl:34
Definition Commandlet.h:41
Definition Object.h:95
Definition World.h:918
Definition Commandlet.h:183
static CORE_API bool Token(const TCHAR *&Str, TCHAR *Result, int32 MaxLen, bool bUseEscape, const TCHAR SingleCharacterDelimiter=TEXT('\0'))
Definition Parse.cpp:846