Skip to content

Commit

Permalink
Merge branch 'pr549' into stable
Browse files Browse the repository at this point in the history
* pr549:
  (GH-468) Log help to standard out, not standard error

Fixes #468
  • Loading branch information
ferventcoder committed Jan 18, 2016
2 parents 15198fa + 40001d0 commit d9d59ff
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
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);
}

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

0 comments on commit d9d59ff

Please sign in to comment.