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

Chocolatey command help output written to standard error instead of standard out #468

Closed
jbuedel opened this issue Oct 16, 2015 · 16 comments

Comments

@jbuedel
Copy link
Contributor

commented Oct 16, 2015

If I issue choco -h | more I get paged output, as expected. choco source -h | more never pages. That is, all output is dumped to the console immediately.

This happens with all the subcommands I tried, including 'search', 'list', and 'source'.

@ferventcoder

This comment has been minimized.

Copy link
Member

commented Oct 16, 2015

Hi,
Choco is not a powershell command, nor does it have powershell output. If
more does not work for stdout, then that is likely the issue.

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 notifications@github.com wrote:

If I issue choco -h | more I get paged output, as expected. choco source
-h | more never pages. That is, all output is dumped to the console
immediately.

This happens all the subcommands I tried, including 'search', 'list', and
'source'.


Reply to this email directly or view it on GitHub
#468.

Rob
"Be passionate in all you do"

http://devlicio.us/blogs/rob_reynolds
http://ferventcoder.com
http://twitter.com/ferventcoder

@jbuedel

This comment has been minimized.

Copy link
Contributor Author

commented Oct 16, 2015

I'm pretty sure powershell's more works with standard output. git log | more does what I expect at least. Git obviously isn't a powershell command either.

Anyway, regardless of what is right, chocolatey is inconsistent in the way it outputs subcommand help versus just choco help.

@ferventcoder

This comment has been minimized.

Copy link
Member

commented Oct 22, 2015

Anyway, regardless of what is right, chocolatey is inconsistent in the way it outputs subcommand help versus just choco help.

It doesn't do anything different from a technical perspective.

@jbuedel

This comment has been minimized.

Copy link
Contributor Author

commented Oct 22, 2015

Are you not seeing the behavior I described?

@jbuedel jbuedel closed this Oct 22, 2015
@jbuedel jbuedel reopened this Oct 22, 2015
@ferventcoder

This comment has been minimized.

Copy link
Member

commented Oct 23, 2015

I don't see paged output for either.

@jbuedel

This comment has been minimized.

Copy link
Contributor Author

commented Oct 23, 2015

Hmm. I've confirmed it on two separate machines now. I suppose it is possible that my powershell is tweaked similarly on both machines, yet different than yours. I'll see if I can duplicate on other machines.

@jbuedel

This comment has been minimized.

Copy link
Contributor Author

commented Oct 23, 2015

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.

@ferventcoder

This comment has been minimized.

Copy link
Member

commented Oct 23, 2015

Ah, sweet. Yeah, the options should not be written to stderr. I have a feeling that is either something I was doing or something embedded into NDesk.Options that needs fixed.

@ferventcoder

This comment has been minimized.

Copy link
Member

commented Oct 23, 2015

@jbuedel Yes you may implement a fix. :)

@ferventcoder

This comment has been minimized.

Copy link
Member

commented Oct 23, 2015

Target stable for quickest results.

@ferventcoder

This comment has been minimized.

Copy link
Member

commented Dec 23, 2015

@jbuedel ping - I'm looking for this coming up soon. If you still want to provide a fix let me know, otherwise I will assume you got busy and will handle this. 👍

@jbuedel

This comment has been minimized.

Copy link
Contributor Author

commented Dec 23, 2015

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.

On Dec 23, 2015, at 12:55 PM, Rob Reynolds notifications@github.com wrote:

@jbuedel ping - I'm looking for this coming up soon. If you still want to provide a fix let me know, otherwise I will assume you got busy and will handle this.


Reply to this email directly or view it on GitHub.

@secretGeek

This comment has been minimized.

Copy link
Contributor

commented Jan 15, 2016

I am signing up to help with this as I was "bitten" by this problem today.

@ferventcoder ferventcoder added this to the 0.9.10 milestone Jan 15, 2016
@ferventcoder

This comment has been minimized.

Copy link
Member

commented Jan 15, 2016

@secretGeek target stable if you can - otherwise I will rebase onto stable when merging. 👍

secretGeek added a commit to secretGeek/choco that referenced this issue Jan 16, 2016
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.
@secretGeek

This comment has been minimized.

Copy link
Contributor

commented Jan 16, 2016

This is my first public PR. Any problems I'll do my best to resolve ;)

@gep13

This comment has been minimized.

Copy link
Member

commented Jan 17, 2016

@secretGeek said...
This is my first public PR. Any problems I'll do my best to resolve ;)

Thanks for your contribution! 👍

ferventcoder added a commit that referenced this issue Jan 18, 2016
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.
ferventcoder added a commit that referenced this issue Jan 18, 2016
* stable:
  (GH-468) Log help to standard out, not standard error
@ferventcoder ferventcoder added 3 - Done and removed 0 - Backlog labels Jan 18, 2016
@ferventcoder ferventcoder self-assigned this Jan 18, 2016
@ferventcoder ferventcoder changed the title Chocolatey command help output breaks powershell more function Chocolatey command help output written to standard error instead of standard out Jan 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.