| | | 1 | | using System.Collections.Generic; |
| | | 2 | | using System.Text.RegularExpressions; |
| | | 3 | | |
| | | 4 | | namespace DirectSight; |
| | | 5 | | |
| | | 6 | | /// <summary> |
| | | 7 | | /// Name of the command line arguments. |
| | | 8 | | /// </summary> |
| | | 9 | | internal static class CommandLineArgumentNames |
| | | 10 | | { |
| | | 11 | | /// <summary> |
| | | 12 | | /// The reports. |
| | | 13 | | /// </summary> |
| | | 14 | | public const string Reports = "reports"; |
| | | 15 | | |
| | | 16 | | /// <summary> |
| | | 17 | | /// The target directory. |
| | | 18 | | /// </summary> |
| | | 19 | | public const string TargetDirectory = "targetdir"; |
| | | 20 | | |
| | | 21 | | /// <summary> |
| | | 22 | | /// Whether or not to run the test in debugging mode (more verbose logging) |
| | | 23 | | /// </summary> |
| | | 24 | | public const string DebugMode = "debug"; |
| | | 25 | | |
| | | 26 | | /// <summary> |
| | | 27 | | /// All valid command line parameter names. |
| | | 28 | | /// </summary> |
| | 1 | 29 | | private static readonly HashSet<string> ValidNames = [ |
| | 1 | 30 | | DebugMode, |
| | 1 | 31 | | Reports, |
| | 1 | 32 | | TargetDirectory |
| | 1 | 33 | | ]; |
| | | 34 | | |
| | | 35 | | /// <summary> |
| | | 36 | | /// Gets the regex to parse command line parameters. |
| | | 37 | | /// </summary> |
| | 10 | 38 | | internal static Regex CommandLineParameterRegex { get; } = new Regex("^-(?<key>[a-z]{5,}):(?<value>.+)$", RegexOptio |
| | | 39 | | |
| | | 40 | | /// <summary> |
| | | 41 | | /// Gets a value indicating whether a command line parameter name is valid. |
| | | 42 | | /// </summary> |
| | | 43 | | /// <param name="name">The command line parameter name.</param> |
| | | 44 | | /// <returns><c>true</c> if command line parameter is valid; otherwise <c>false</c>.</returns> |
| | | 45 | | public static bool IsValid(string name) |
| | 9 | 46 | | { |
| | 9 | 47 | | if (name == null) |
| | 0 | 48 | | { |
| | 0 | 49 | | return false; |
| | | 50 | | } |
| | | 51 | | |
| | 9 | 52 | | return ValidNames.Contains(name); |
| | 9 | 53 | | } |
| | | 54 | | } |