-
Notifications
You must be signed in to change notification settings - Fork 124
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
Detect -strip
and print a more helpful error message
#550
Comments
I can confirm: for seasoned users of |
To me it's all fully expected (see below). The only unfortunate trap here is that two PNG optimizers with same options I can also cite one precedent for helping common user mistakes:
In my own programs I also try to usually be extra helpful (if code can feasibly do it, I don't want to burden a human, the human user is there to complete their desired task, not remember niche details specific to my program they might very rarely use), for example I have one program that requires 2 args: a URL and a file, so I don't enforce which argument is which of them since I can in code figure that out from checking if file exists and seeing My issue text above was brief to be quick to read, but since I see you @ace-dent are interested in or surprised by option handling in the other issue I will write this longer message: As I come from more Linux (with GNU userland) CLI experience to me it's fully expected what The benefit (as you saw in the other issue) is that you don't run out of letters for short options, scripts can look clearer, short options can still be grouped and not be confused for long options. It also merges nicely with convention to use The downside is that newer users or experienced users more familiar with DOS, Windows, non-GNU BSD and so on might be surprised. The fact that many common tools (even Windows especially is a trap since it's a popular OS, with many less experienced and less technical or still learning or underage users (a child learning programming might not understand VMs and not dare reinstall Linux onto computer their non-technical parents gave them), with much less CLI emphasis, and all over the place in case of (often closed source, distributed with no docs, just as a binary) tools written in C or C++ with handrolled option parsers, and the option character is technically just a single Even more interesting and confusing option is the help option. Depending on OS, convention (or lack of it) and so on, each of: |
Hi @FRex Oxipng isn't advertised as being a drop-in replacement for Optipng and one would assume users would check the help if they got an error they couldn't figure out. If this is a common problem then certainly we might need to do something but so far I believe you're the first to mention it here. One possibility might be to print (shorter) help when an argument parsing error occurs, though I'm not sure if clap has any options to do that. |
The README says it began as a Rust reimplementation of Optipng so some hand-holding for users coming from it seems reasonable to me. I'm also not the first to mention it, ace-dent ran into dash amount confusion in their issue (linked above) when using both tools in a script too. |
Sorry, I meant specifically the |
My 2¢ - this is a documentation issue.
oxipng.exe -h
oxipng.exe -help
oxipng.exe --help
oxipng.exe -?
oxipng.exe --?
oxipng.exe -H
oxipng.exe --H
oxipng.exe -HELP
oxipng.exe --HELP
oxipng.exe /h
oxipng.exe /help |
Wait, why does Just throwing an idea out (don't shoot! 🙆🏾 ): is it worth kicking this whole thing over to a switch-matching library? It fairly reeks of the glob-type issues. |
@TPS oxipng uses the Rust de-facto standard argument parsing library clap 🙂 If you think this is important, I could suggest to clap that they accept There's nothing oxipng itself can/should do in its own code for any of this, other than improvements to the Readme. |
The Read Me has been updated with a few clarifications around these issues. Hope it helps 🙂 |
Before discovering
oxipng
I usedoptipng
so I'm used to single dash option-strip all
.oxipng -strip
is equal tooxipng -s -t rip
so it produces an error message that "rip" is not a valid number of threads.Despite CLI, GNU and Linux experience the error still confuses me for a second or two because I'm so used to
optipng
.I assume it's even more confusing to others who are used to
optipng
or have less experience.This option is particularly tricky because invocations
optipng -o max -strip all *.png
andoxipng -o max --strip all *.png
look and do exactly the same in both programs and differ only by extra dash.I propose checking args for
-strip
before callingget_matches_from(std::env::args())
to print an error message explaining long options with double dash.Another solution would be aliasing
-strip
to--strip
if the args parsing library allows it (I don't know if it does).I can prepare this as a PR if you wish.
The text was updated successfully, but these errors were encountered: