Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Chocolatey command help output written to standard error instead of standard out #468
You may want to use the real more or install the less commands to get what you desire.
On Friday, October 16, 2015, Josh Buedel firstname.lastname@example.org wrote:
I'm pretty sure powershell's more works with standard output.
Anyway, regardless of what is right, chocolatey is inconsistent in the way it outputs subcommand help versus just
I've figured out what is going on. The short explanation is: the option descriptions text that follows "Option and Switches" part of the help text is written to StdErr. The rest of the output goes through the logging system and ultimately comes out of StdOut.
The longer explanation is that the inconsistency I saw with paging was that the 'choco -h' command had enough StdOut text that it would page. 'choco list -h' has very little StdOut output and did not need to page. The tricky bit was that the StdErr output, in both cases, is going directly to the screen. It actually appears above the StdOut text in my console. There is enough option description text that it scrolls, giving the appearance that more is not paging. I guess StdErr beats StdOut to the console, probably because StdOut is passing through more.com first, slowing it down.
If you agree that all the help text should be consistently written to StdOut, I suggest that the fix would occur in ConfigurationOptions.show_help(). One solution is to replace Console.Error with Console.Out as the parameter to OptionSet.WriteOptionDescriptions(). Another is to capture the text OptionSet.WriteOptionDecriptions() writes to an in memory stream and then push that text through the logging system. This would be more consistent with how the rest of the help text is written.
If you agree with either of my proposed solutions I'd like to submit a pull request. Just let me know how you'd like it handled.
Hi Rob. Yeah unfortunately I've just been too busy to dig into it. I haven't forgotten though. I'll see what I can do over the next few days, but if you beat me to it, no problem.
Commands such as: choco list -help | more choco list -help | out-host -paging ...did not page as expected. Similarly: choco -help | out-file HelpDetails.txt did not deliver all of the help output to the file. (The workaround of using 2>&1 (or *>&1) is burdensome for the very people who need help in the first place.) So, in line with normal use of NDesk OptionSet, the option descriptions are now written to Console.Out not Console.Error.
Previously, help information was written out to stderr due to how NDesk OptionSet provides the help output. This causes commands such as the following to not page as expected: * `choco list -help | more` * `choco list -help | out-host -paging` Similarly `choco -help | out-file HelpDetails.txt` does not deliver all of the help output to the file. While there is a workaround of using `2>&1` (or `*>&1`) is burdensome for the very people who need help in the first place. Help information should instead be provided in stdout and not in stderr. This allows us to avoid these issues entirely.