PageRenderTime 43ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/Mercurial.Net/ICommand.cs

#
C# | 95 lines | 31 code | 8 blank | 56 comment | 0 complexity | 365607772b4e2890d7802acb03601eea MD5 | raw file
Possible License(s): BSD-3-Clause, GPL-2.0
  1. using System.Collections.Generic;
  2. using System.Collections.ObjectModel;
  3. namespace Mercurial
  4. {
  5. /// <summary>
  6. /// This interface must be implemented by all classes that implement the command
  7. /// pattern for executing Mercurial and TortoiseHg commands.
  8. /// </summary>
  9. public interface ICommand
  10. {
  11. /// <summary>
  12. /// Gets the command to execute with the Mercurial command line client.
  13. /// </summary>
  14. string Command
  15. {
  16. get;
  17. }
  18. /// <summary>
  19. /// Gets all the arguments to the <see cref="Command"/>, or an
  20. /// empty array if there are none.
  21. /// </summary>
  22. IEnumerable<string> Arguments
  23. {
  24. get;
  25. }
  26. /// <summary>
  27. /// Gets any additional arguments to the <see cref="Command"/>, or an
  28. /// empty collection if there are none.
  29. /// </summary>
  30. Collection<string> AdditionalArguments
  31. {
  32. get;
  33. }
  34. /// <summary>
  35. /// Gets the <see cref="IMercurialCommandObserver"/> that will be informed of
  36. /// execution progress. Can be <c>null</c> in case there is no observer.
  37. /// </summary>
  38. IMercurialCommandObserver Observer
  39. {
  40. get;
  41. }
  42. /// <summary>
  43. /// Gets the timeout in seconds for how long to wait for the command to
  44. /// complete successfully before terminating it and throwing an exception. A
  45. /// typical default value is 60.
  46. /// </summary>
  47. int Timeout
  48. {
  49. get;
  50. }
  51. /// <summary>
  52. /// Validates the command configuration. This method should throw the necessary
  53. /// exceptions to signal missing or incorrect configuration (like attempting to
  54. /// add files to the repository without specifying which files to add.)
  55. /// </summary>
  56. void Validate();
  57. /// <summary>
  58. /// This method is called before the command is executed. You can use this to
  59. /// store temporary files (like a commit message or similar) that the
  60. /// <see cref="Arguments"/> refer to, before the command is executed.
  61. /// </summary>
  62. void Before();
  63. /// <summary>
  64. /// This method is called after the command has been executed. You can use this to
  65. /// clean up after the command execution (like removing temporary files), and to
  66. /// react to the exit code from the command line client. If the exit code is
  67. /// considered a failure, this method should throw the correct exception.
  68. /// </summary>
  69. /// <param name="exitCode">
  70. /// The exit code from the command line client. Typically 0 means success, but this
  71. /// can vary from command to command.
  72. /// </param>
  73. /// <param name="standardOutput">
  74. /// The standard output of the execution, or <see cref="string.Empty"/> if there
  75. /// was none.
  76. /// </param>
  77. /// <param name="standardErrorOutput">
  78. /// The standard error output of the execution, or <see cref="string.Empty"/> if
  79. /// there was none.
  80. /// </param>
  81. /// <remarks>
  82. /// Also note that if the command exit code is considered a success, this method
  83. /// should parse the output and prepare any results based on it.
  84. /// </remarks>
  85. void After(int exitCode, string standardOutput, string standardErrorOutput);
  86. }
  87. }