Skip to content

Commit

Permalink
Merge branch 'stable'
Browse files Browse the repository at this point in the history
* stable:
  (GH-468) Log help to standard out, not standard error
  • Loading branch information
ferventcoder committed Jan 18, 2016
2 parents b7c3b97 + d9d59ff commit c3d641b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
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);
}

protected Action because;
Expand Down
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
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
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

0 comments on commit c3d641b

Please sign in to comment.