diff --git a/AzureLiquid.Preview/PreviewProcessArguments.cs b/AzureLiquid.Preview/PreviewProcessArguments.cs index 91e6495..2a490c7 100644 --- a/AzureLiquid.Preview/PreviewProcessArguments.cs +++ b/AzureLiquid.Preview/PreviewProcessArguments.cs @@ -18,6 +18,7 @@ public class PreviewProcessArguments /// /// Gets the index of the argument, if it exists. /// + /// The arguments. /// The key. /// The index of the argument. private static int GetArgumentIndex(string[] args, string key) @@ -46,6 +47,14 @@ private static bool IsArgMatch(string arg, string key) return string.CompareOrdinal(arg, "--" + key) == 0; } + /// + /// Gets a value indicating whether the specific argument key was found in the arguments. + /// + /// The passed arguments. + /// The key. + /// true if the argument was found, otherwise false, + public static bool HasArgument(string[] args, string key) => args.Any(arg => IsArgMatch(arg, key)); + /// /// Parses the argument value. /// @@ -56,8 +65,8 @@ public string ParsePath(string[] args, string key) { var index = GetArgumentIndex(args, key); return - index == -1 || index - 1 >= args?.Length || args == null ? string.Empty : // No match, or no arguments passed - Path.GetFullPath(args[index + 1], _path) // Argument found, parsing path - ?? string.Empty; // Argument found, but path is invalid + index == -1 || index - 1 >= args?.Length || args == null + ? string.Empty // No match, or no arguments passed + : Path.GetFullPath(args[index + 1], _path); // Argument found, parsing path } } \ No newline at end of file