// -------------------------------------------------------------------------------------------------------------------- // // // // // Perforce integrate program. // // -------------------------------------------------------------------------------------------------------------------- namespace PerforceIntegrate { using System; using Rockstar.AssetManager.Infrastructure.Enums; using Rockstar.AssetManager.Main; /// /// The program. /// public class Program { /// /// The branch. /// private static string branch; /// /// The resolve action. /// private static ResolveAction resolveAction; /// /// The P4 port. /// private static string p4Port; /// /// The P4 workspace. /// private static string p4Workspace; /// /// The P4 user. /// private static string p4User; /// /// The P4 password. /// private static string p4Password; /// /// The P4 depot root. /// private static string p4DepotRoot; /// /// The main method. /// /// /// The args. /// public static void Main(string[] args) { ParseArgs(args); var assetManager = AssetManagerFactory.GetInstance( AssetManagerType.Perforce, null, p4Port, p4Workspace, p4User, p4Password, p4DepotRoot); // Check we can connect to asset manager assetManager.Connect(); var app = new PerforceIntegrate(assetManager); string changeListNumber; if (!app.Integrate(branch, resolveAction, out changeListNumber)) { Environment.Exit(-1); } } /// /// Parse the args. /// /// /// The args. /// private static void ParseArgs(string[] args) { for (var i = 0; i < args.Length; i++) { if (!args[i].StartsWith("-")) { continue; } if (i + 1 == args.Length) { Help(); throw new Exception("Invalid args"); } switch (args[i]) { case "-branch": { branch = args[i + 1]; break; } case "-resolve": { if (!Enum.TryParse(args[i + 1], true, out resolveAction)) { Help(); throw new Exception("Failed to parse resolve action: " + args[i + 1]); } break; } case "-p4host": { p4Port = args[i + 1]; break; } case "-p4client": { p4Workspace = args[i + 1]; break; } case "-p4user": { p4User = args[i + 1]; break; } case "-p4passwd": { p4Password = args[i + 1]; break; } case "-p4depotroot": { p4DepotRoot = args[i + 1]; break; } } } if (string.IsNullOrEmpty(branch)) { throw new ArgumentException("Branch required"); } if (resolveAction == ResolveAction.Unknown) { throw new ArgumentException("Resolve action required"); } } /// /// Print help info. /// private static void Help() { Console.WriteLine("Usage: perforceintegrate.exe -branch -resolve "); } } }