leo / args

Toolkit for building command line interfaces
https://npmjs.com/args
MIT License
461 stars 30 forks source link

Log message for missing option lacks newline #129

Closed AlexGustafsson closed 6 years ago

AlexGustafsson commented 6 years ago

When an invalid option is found, the log message that is written to stdout lacks a newline.

~/Documents/GitHub$ hyper -i hyperline
-The option "i" is unknown.~/Documents/GitHub$
+The option "i" is unknown.
+~/Documents/GitHub$

The faulty line is here:

https://github.com/leo/args/blob/490e18c5a35fc099f01fe7b64b584b18b4aedede/lib/utils.js#L147

This issue resulted in the following post over at Zeit's Hyper repository: https://github.com/zeit/hyper/issues/3105

thefifthisa commented 6 years ago

@AlexGustafsson Hey! So I was working on this and realized the newline is actually present in these lines that are concatenated to The option ... is unknown.:

https://github.com/leo/args/blob/490e18c5a35fc099f01fe7b64b584b18b4aedede/lib/utils.js#L150 https://github.com/leo/args/blob/490e18c5a35fc099f01fe7b64b584b18b4aedede/lib/utils.js#L169

Do they not appear for you?

ntwcklng commented 6 years ago

This is weird. As @thefifthisa said, the newline should be printed, because if there is a similar option, we print it out, if not we show the whole help command (args@3.0.8 is used): https://github.com/leo/args/blob/3.0.8/lib/utils.js#L117-L155

On 3.0.8 and 5.0.0 i can't recreate this error.

AlexGustafsson commented 6 years ago

It is weird indeed. Using Hyper with WSL I only get the first output (that the option is unknown). Using CMD or PowerShell on Windows I get the full help.

Since WSL doesn't formally support Hyper's CLI interface, I'm using the alias hyper -> cmd.exe /c hyper. Using that in CMD or PowerShell works fine, so the alias itself doesn't seem to change anything.

I tried piping all output to stdout to see if that could be an issue (that hyper lost stderr etc.) but that didn't help.

As of now I can no longer see how any of these issues could be related to the args package. I'm sorry for any inconvenience.

ntwcklng commented 6 years ago

Okay, i will close this for now. @thefifthisa thank you for digging in!