main
cs 116 lines 5.92 KB
Raw
1 // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3 namespace WixToolset.Extensibility.Services
4 {
5 using System.Collections.Generic;
6 using WixToolset.Data;
7
8 /// <summary>
9 /// Provides the command-line arguments.
10 /// </summary>
11 public interface ICommandLineParser
12 {
13 /// <summary>
14 /// Gets the argument that caused the error.
15 /// </summary>
16 string ErrorArgument { get; }
17
18 /// <summary>
19 /// Validates that a valid switch (starts with "/" or "-"), and returns a bool indicating its validity
20 /// </summary>
21 /// <param name="argument">The string check.</param>
22 /// <returns>True if a valid switch, otherwise false.</returns>
23 bool IsSwitch(string argument);
24
25 /// <summary>
26 /// Gets the current argument as a file or displays an error.
27 /// </summary>
28 /// <param name="argument">Current argument used in the error message if necessary.</param>
29 /// <param name="fileType">Type of file displayed in the error message if necessary.</param>
30 /// <returns>The fully expanded path if the argument is a file path, otherwise null.</returns>
31 string GetArgumentAsFilePathOrError(string argument, string fileType);
32
33 /// <summary>
34 /// Adds the current argument as a file to the list or displays an error.
35 /// </summary>
36 /// <param name="argument">Current argument used in the error message if necessary.</param>
37 /// <param name="fileType">Type of file displayed in the error message if necessary.</param>
38 /// <param name="paths">List to add the fully expanded path if the argument is a file path.</param>
39 /// <returns>True if the argument is a file path, otherwise false.</returns>
40 bool GetArgumentAsFilePathOrError(string argument, string fileType, IList<string> paths);
41
42 /// <summary>
43 /// Gets the next argument or displays error if no argument is available.
44 /// </summary>
45 /// <param name="argument">Current argument used in the error message if necessary.</param>
46 /// <returns>The next argument if present or null</returns>
47 string GetNextArgumentOrError(string argument);
48
49 /// <summary>
50 /// Adds the next argument to a list or displays error if no argument is available.
51 /// </summary>
52 /// <param name="argument">Current argument used in the error message if necessary.</param>
53 /// <param name="arguments">List to add the argument to.</param>
54 /// <returns>True if an argument is available, otherwise false.</returns>
55 bool GetNextArgumentOrError(string argument, IList<string> arguments);
56
57 /// <summary>
58 /// Gets the next argument as a directory or displays an error.
59 /// </summary>
60 /// <param name="argument">Current argument used in the error message if necessary.</param>
61 /// <returns>The fully expanded path if the argument is a directory, otherwise null.</returns>
62 string GetNextArgumentAsDirectoryOrError(string argument);
63
64 /// <summary>
65 /// Adds the next argument as a directory to the list or displays an error.
66 /// </summary>
67 /// <param name="argument">Current argument used in the error message if necessary.</param>
68 /// <param name="directories">List to add the fully expanded directory if the argument is a file path.</param>
69 /// <returns>True if the argument is a directory, otherwise false.</returns>
70 bool GetNextArgumentAsDirectoryOrError(string argument, IList<string> directories);
71
72 /// <summary>
73 /// Gets the next argument as a file or displays an error.
74 /// </summary>
75 /// <param name="argument">Current argument used in the error message if necessary.</param>
76 /// <param name="filePurpose">Purpose of the required file.</param>
77 /// <returns>The fully expanded path if the argument is a file path, otherwise null.</returns>
78 string GetNextArgumentAsFilePathOrError(string argument, string filePurpose);
79
80 /// <summary>
81 /// Adds the next argument as a file to the list or displays an error.
82 /// </summary>
83 /// <param name="argument">Current argument used in the error message if necessary.</param>
84 /// <param name="fileType">Type of file displayed in the error message if necessary.</param>
85 /// <param name="paths">List to add the fully expanded path if the argument is a file path.</param>
86 /// <returns>True if the argument is a file path, otherwise false.</returns>
87 bool GetNextArgumentAsFilePathOrError(string argument, string fileType, IList<string> paths);
88
89 /// <summary>
90 /// Reports a command line error for the provided argument.
91 /// </summary>
92 /// <param name="argument">Argument that caused the error.</param>
93 /// <param name="message">Message to report.</param>
94 void ReportErrorArgument(string argument, Message message = null);
95
96 /// <summary>
97 /// Tries to get the next argument.
98 /// </summary>
99 /// <param name="argument">Next argument if available.</param>
100 /// <returns>True if argument is available, otherwise false.</returns>
101 bool TryGetNextSwitchOrArgument(out string argument);
102
103 /// <summary>
104 /// Looks ahead to the next argument without moving to the next argument.
105 /// </summary>
106 /// <returns>Next argument if available, otherwise null.</returns>
107 string PeekNextArgument();
108
109 /// <summary>
110 /// Tries to looks ahead to the next argument without moving to the next argument.
111 /// </summary>
112 /// <param name="argument">Argument found if present.</param>
113 /// <returns>True if argument is found, otherwise false.</returns>
114 bool TryPeekNextArgument(out string argument);
115 }
116 }