Aucune description
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

ProcessCommand.cs 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEditor;
  4. using Codice.LogWrapper;
  5. using Unity.PlasticSCM.Editor.Hub.Operations;
  6. namespace Unity.PlasticSCM.Editor.Hub
  7. {
  8. internal static class ProcessCommand
  9. {
  10. internal const string IS_PROCESS_COMMAND_ALREADY_EXECUTED_KEY =
  11. "PlasticSCM.ProcessCommand.IsAlreadyExecuted";
  12. internal const string IS_PLASTIC_COMMAND_KEY =
  13. "PlasticSCM.ProcessCommand.IsPlasticCommand";
  14. internal static void Initialize()
  15. {
  16. EditorApplication.update += RunOnceWhenAccessTokenIsInitialized;
  17. }
  18. static void RunOnceWhenAccessTokenIsInitialized()
  19. {
  20. if (string.IsNullOrEmpty(CloudProjectSettings.accessToken))
  21. return;
  22. EditorApplication.update -= RunOnceWhenAccessTokenIsInitialized;
  23. Execute(CloudProjectSettings.accessToken);
  24. }
  25. static void Execute(string unityAccessToken)
  26. {
  27. if (SessionState.GetBool(
  28. IS_PROCESS_COMMAND_ALREADY_EXECUTED_KEY, false))
  29. {
  30. return;
  31. }
  32. ProcessCommandFromArgs(
  33. Environment.GetCommandLineArgs(),
  34. unityAccessToken);
  35. SessionState.SetBool(
  36. IS_PROCESS_COMMAND_ALREADY_EXECUTED_KEY, true);
  37. }
  38. internal static void ProcessCommandFromArgs(
  39. string[] commandLineArgs,
  40. string unityAccessToken)
  41. {
  42. Dictionary<string, string> args =
  43. CommandLineArguments.Build(commandLineArgs);
  44. mLog.DebugFormat(
  45. "Processing Unity arguments: {0}",
  46. string.Join(" ", commandLineArgs));
  47. ParseArguments.Command command =
  48. ParseArguments.GetCommand(args);
  49. if (!command.IsValid())
  50. return;
  51. SessionState.SetBool(
  52. IS_PLASTIC_COMMAND_KEY, true);
  53. OperationParams parameters = OperationParams.
  54. BuildFromCommand(command, unityAccessToken);
  55. switch (command.OperationType)
  56. {
  57. case ParseArguments.Command.Operation.CreateWorkspace:
  58. CreateWorkspace.LaunchOperation(parameters);
  59. return;
  60. case ParseArguments.Command.Operation.DownloadRepository:
  61. DownloadRepository.LaunchOperation(parameters);
  62. return;
  63. }
  64. }
  65. static readonly ILog mLog = LogManager.GetLogger("ProcessCommand");
  66. }
  67. }