// Copyright Epic Games, Inc. All Rights Reserved. #pragma once #include "CoreMinimal.h" #include "CmdLineParameter.h" #include "Misc/Paths.h" namespace FSubmitToolCmdLine { const FString P4Server = TEXT("server"); const FString P4Client = TEXT("client"); const FString P4User = TEXT("user"); const FString P4ChangeList = TEXT("cl"); const FString RootDir = TEXT("root-dir"); const FString ParameterFile = TEXT("param-file"); const TArray> SubmitToolCmdLineArgs = { MakeShared(P4Server, true, TEXT("Perforce Server information, expected with format '
:'")), MakeShared(P4Client, true, TEXT("Perforce workspace name.")), MakeShared(P4User, true, TEXT("Perforce user name.")), MakeShared(P4ChangeList, true, TEXT("Perforce changelist number to submit."), [](const FString& InValue) { return InValue.IsNumeric() || InValue.Equals(TEXT("default")); }), MakeShared(RootDir, false, TEXT("Root directory for the branch this change is part of"), nullptr, [](FString& OutValue) { TArray CharactersToRemove{ '\\', '\"' , '\''}; size_t Left = 0; size_t Right = OutValue.Len() - 1; bool bKeepLooping = true; while (bKeepLooping) { bKeepLooping = false; if (CharactersToRemove.Contains(OutValue[Left])) { Left++; bKeepLooping = true; } if (CharactersToRemove.Contains(OutValue[Right])) { Right--; bKeepLooping = true; } } OutValue.MidInline(Left, (Right - Left) + 1); #if PLATFORM_WINDOWS if (OutValue[1] == ':') { OutValue[0] = FChar::ToUpper(OutValue[0]); } #endif FPaths::NormalizeDirectoryName(OutValue); }), MakeShared(ParameterFile, false, TEXT("Submit tool parameters XML override.")), }; } class FCmdLineParameters { public: FCmdLineParameters(); bool ValidateParameters() const; void LogParameters() const; const static FCmdLineParameters& Get(); bool Contains(const FString& InKey) const; bool GetValue(const FString& InKey, FString& OutValue) const; private: const static FCmdLineParameters Instance; const TArray> Parameters; };