PageRenderTime 23ms CodeModel.GetById 17ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/Mercurial.Net/ICommand.cs

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