Skip to content

Commit

Permalink
Adding simpler CliProgram.ExecuteAndGetOutputAsync() overload
Browse files Browse the repository at this point in the history
  • Loading branch information
Piedone committed Nov 23, 2023
1 parent 9fcb88e commit 3c685e1
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions Lombiq.HelpfulLibraries.Cli/CliProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,27 @@ public async Task ExecuteAsync(
public Task ExecuteAsync(CancellationToken token, params object[] arguments) =>
ExecuteAsync(arguments, additionalExceptionText: null, token);

/// <summary>
/// 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.
/// </summary>
/// <param name="token">Passed into the CliWrap <see cref="Command"/>.</param>
/// <param name="arguments">
/// The arguments passed to the command. If an item is not a <see langword="string"/>, then it's converted using the
/// <see cref="CultureInfo.InvariantCulture"/> formatter.
/// </param>
/// <returns>The standard output as a string.</returns>
/// <exception cref="InvalidOperationException">
/// <para>Thrown if the command fails or outputs to the error stream. The format is like this:</para>
/// <code>
/// The {command} {arguments} command failed with the output below.
/// {additional exception text}
/// {standard error output}
/// </code>
/// </exception>
public Task<string> ExecuteAndGetOutputAsync(CancellationToken token, params object[] arguments) =>
ExecuteAndGetOutputAsync(arguments, additionalExceptionText: null, token);

/// <summary>
/// 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.
Expand Down

0 comments on commit 3c685e1

Please sign in to comment.