Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(GH-468) Send Chocolatey Command Help to standard out not Err #549

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,15 @@ public abstract class ConfigurationOptionsSpecBase : TinySpec

protected Mock<IConsole> console = new Mock<IConsole>();
protected static StringBuilder helpMessageContents = new StringBuilder();
protected TextWriter writer = new StringWriter(helpMessageContents);
protected TextWriter errorWriter = new StringWriter(helpMessageContents);
protected TextWriter outputWriter = new StringWriter(helpMessageContents);

public override void Context()
{
ConfigurationOptions.initialize_with(new Lazy<IConsole>(() => console.Object));
ConfigurationOptions.reset_options();
console.Setup((c) => c.Error).Returns(writer);
console.Setup((c) => c.Error).Returns(errorWriter);
console.Setup((c) => c.Out).Returns(outputWriter);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

}

protected Action because;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ private static void show_help(OptionSet optionSet, Action helpMessage)
helpMessage.Invoke();
}

optionSet.WriteOptionDescriptions(Console.Error);
optionSet.WriteOptionDescriptions(Console.Out);
}
}
}
2 changes: 2 additions & 0 deletions src/chocolatey/infrastructure/adapters/Console.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public System.ConsoleKeyInfo ReadKey(int timeoutMilliseconds)

public TextWriter Error { get { return System.Console.Error; } }

public TextWriter Out { get { return System.Console.Out; } }

public void Write(object value)
{
System.Console.Write(value.to_string());
Expand Down
9 changes: 9 additions & 0 deletions src/chocolatey/infrastructure/adapters/IConsole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ public interface IConsole
/// <filterpriority>1</filterpriority>
TextWriter Error { get; }

/// <summary>
/// Gets the standard output stream.
/// </summary>
/// <returns>
/// A <see cref="T:System.IO.TextWriter" /> that represents the standard output stream.
/// </returns>
/// <filterpriority>1</filterpriority>
TextWriter Out { get; }

/// <summary>
/// Writes the specified string value to the standard output stream.
/// </summary>
Expand Down