From 21b3ed2142e65b57ce44d8b918a9b5e817922319 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Leh=C3=B3czky?= Date: Tue, 14 Nov 2023 02:55:41 +0100 Subject: [PATCH 1/3] Adding params-using CliProgram.GetCommand() overload --- Lombiq.HelpfulLibraries.Cli/CliProgram.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Lombiq.HelpfulLibraries.Cli/CliProgram.cs b/Lombiq.HelpfulLibraries.Cli/CliProgram.cs index 7cb40790..41b31046 100644 --- a/Lombiq.HelpfulLibraries.Cli/CliProgram.cs +++ b/Lombiq.HelpfulLibraries.Cli/CliProgram.cs @@ -18,6 +18,12 @@ public class CliProgram public CliProgram(string command) => _command = command + OperatingSystemHelper.GetExecutableExtension(); + /// + /// Creates a object based on the passed . + /// + public Command GetCommand(params object[] arguments) => + GetCommand(arguments.ToList()); + /// /// Creates a object based on the passed . /// From 9fcb88e1f9d39f841445c9890bdb61727668466c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Leh=C3=B3czky?= Date: Wed, 15 Nov 2023 15:43:39 +0100 Subject: [PATCH 2/3] Clarifying docs on StringExtensions that you shouldn't use --- .../Extensions/StringExtensions.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Lombiq.HelpfulLibraries.Common/Extensions/StringExtensions.cs b/Lombiq.HelpfulLibraries.Common/Extensions/StringExtensions.cs index e26def64..98cf0b8b 100644 --- a/Lombiq.HelpfulLibraries.Common/Extensions/StringExtensions.cs +++ b/Lombiq.HelpfulLibraries.Common/Extensions/StringExtensions.cs @@ -130,14 +130,15 @@ public static string ReplaceOrdinalIgnoreCase(this string text, string oldValue, text.Replace(oldValue, newValue ?? string.Empty, StringComparison.OrdinalIgnoreCase); /// - /// A shortcut for string.Equals(string, StringComparison.Ordinal). + /// Use simple equality check with = instead, since it already uses ordinal string + /// comparison. /// [Obsolete("The string equals operator already uses ordinal string comparison.")] public static bool EqualsOrdinal(this string text, string? value) => throw new NotSupportedException(); /// - /// A shortcut for string.Contains(string, StringComparison.Ordinal). + /// Use string.Contains(string) instead, since it already uses ordinal string comparison.. /// [Obsolete("The string.Contains(value) member method already uses ordinal string comparison.")] public static bool ContainsOrdinal(this string text, string value) => @@ -168,7 +169,7 @@ public static bool EndsWithOrdinal(this string text, string value) => text.EndsWith(value, StringComparison.Ordinal); /// - /// A shortcut for string.Replace(string, string, StringComparison.Ordinal). + /// Use string.Replace(string, string) instead, since it already uses ordinal string comparison.. /// [Obsolete("The string.Replace(oldValue, newValue) member method already uses ordinal string comparison.")] public static string ReplaceOrdinal(this string text, string oldValue, string? newValue = "") => From 3c685e1f1592ebaf7c086d51f9655a15eaceb910 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Leh=C3=B3czky?= Date: Thu, 23 Nov 2023 22:50:53 +0100 Subject: [PATCH 3/3] Adding simpler CliProgram.ExecuteAndGetOutputAsync() overload --- Lombiq.HelpfulLibraries.Cli/CliProgram.cs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Lombiq.HelpfulLibraries.Cli/CliProgram.cs b/Lombiq.HelpfulLibraries.Cli/CliProgram.cs index 41b31046..9011a9b4 100644 --- a/Lombiq.HelpfulLibraries.Cli/CliProgram.cs +++ b/Lombiq.HelpfulLibraries.Cli/CliProgram.cs @@ -76,6 +76,27 @@ public async Task ExecuteAsync( public Task ExecuteAsync(CancellationToken token, params object[] arguments) => ExecuteAsync(arguments, additionalExceptionText: null, token); + /// + /// Calls the command specified in the constructor with the provided arguments, and returns the standard output as a + /// string. If the process doesn't succeed or outputs to the standard error stream then an exception is thrown. + /// + /// Passed into the CliWrap . + /// + /// The arguments passed to the command. If an item is not a , then it's converted using the + /// formatter. + /// + /// The standard output as a string. + /// + /// Thrown if the command fails or outputs to the error stream. The format is like this: + /// + /// The {command} {arguments} command failed with the output below. + /// {additional exception text} + /// {standard error output} + /// + /// + public Task ExecuteAndGetOutputAsync(CancellationToken token, params object[] arguments) => + ExecuteAndGetOutputAsync(arguments, additionalExceptionText: null, token); + /// /// Calls the command specified in the constructor with the provided arguments, and returns the standard output as a /// string. If the process doesn't succeed or outputs to the standard error stream then an exception is thrown.