-
Notifications
You must be signed in to change notification settings - Fork 480
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
Support Repeated Arguments using standard syntax instead of the non-standard and confusing syntax. #357
Comments
Updated the title as it was from a prior iteration of what I wrote from when I was testing this to make sure I had all the facts. |
Hi @duaneking, can you provide some more info on this? Searches on a variation of "screen reader argument parsing" don't really turn up much. |
Respectfully, that's not the point as chasing a specific application devalues the consistency argument; The golden rule of thumb on argument parsing is the standard "getopt" pattern/toolset. Its the standard for a reason. See http://man7.org/linux/man-pages/man3/getopt.3.html for more details. |
Thanks, I'm asking specifically about "last argument wins" vs. "error on duplicated argument". getopt doesn't really prescribe one or the other, as it's left to the implementer how the program behaves when an argument is seen twice. |
In Linux/Posix systems the universal rule I have seen used in the past 20 or so years of my experience is that if a parameter argument is only required once and is used twice, the second usage overwrites the first one and thus the first argument is simply parsed, validated, and then ignored. |
The library's intention certainly is to follow getopt() semantics, as @nemec mentioned its not set in stone according to getopt on this issue though. @duaneking can you provide a few examples you're talking about? This will help nail down an implementation. Maybe a separate branch for this could be started to address these concerns, make changes to the code base to support it, and fix the tests that make incorrect assumptions Makes sense that |
I will try match the implementation of CommandLineParser library with the standard of getopt of GNU and POSIX specifications as described in linuxfoundation.org Option Characteristics
POSIX specifies that: applications using getopt must obey the following syntax guidelines:
in short:
Repeating option There is no standard for the repeating options in the POSIX/getopt and it's left for the implementer
But the syntax
For example, in the downloader utility of vs2017, I can do:
The standard syntax of the command line:
AFAIK, C may be
It's accepted if the parameter is defined as string not In the two cases parser shouldn't fire error and define the parameter value based on the data type scalar or sequence. |
Is this still being considered? This seems like an optional parser setting that we could opt-in to without breaking the old behavior. I have a potential fix that I could put a PR up for, but I want to make sure this is something that would be accepted. |
Welcome @tydunkel to the project. |
For scalars the last one wins. For sequences it will merge all options into one sequence. If the parser is opted-in to this behavior, the command line can only use multi-instance options for a sequence. e.g. |
It looks fine. You are welcome to submit PR. |
+1 for having this! @tydunkel I've peek your branch and you seem to already have this there. Can you submit that PR? 😉 😁 |
@josesimoes @moh-hassan #594 is a PR for @tydunkel's work on this feature. I haven't done anything to it except fix the merge conflicts with the current state of the |
The support people need is : derp.exe -c foo-c bar In this case either both foo and bar would be in the option list (in the case of supporting multiple values in that case) or its simply setting -c to the value of foo then ignoring that and setting the value of -c to bar. |
Using the newest version, Despite the fact I declared the option as a list in my options class, I'm not able to add multiple options when I use the standard linux command argument patterns, but I am if I use a pattern that breaks compatibility with some accessibility software used by the disabled.
For example the following creates a repeatedoption error:
And the command line:
..Results in an error.
But if I look at the code here on github (because this isn't documented anywhere I can find, at all, despite being a critical use case) I can get it to work if I do:
Respectfully, my first thought on seeing this was "This is a critical defect that explicitly neuters the potential of this library".
My personal usage goal is in the style of core linux tools like grep, awk, sed, etc. So in my mind this should work exactly like the standard linux flow, where either the last argument wins in the case of only needing one on the command, or in the case of expecting a possible list due to duplicate use of an option, a list should be built up in the order the command line options are used.
Now we can clearly see that this does work, its just using a very inconsistent syntax that doesn't take into account the needs of screenreaders (So this library technically discriminates against the disabled. Did you know this?) or consistent linux users - look at the standard grep tool, you can use the same argument multiple times and it just works - but only after looking at the source code could I hunt this down because I could not find any data on repeated options or this confusing and inconsistent syntax anywhere in the docs.
Looking at the code, the tests explicitly do not support the industry standard syntax. This is even more frustrating, because its effectively giving the finger to people who want to support accessibility tools that DEPEND on this classic, standard, "last one wins" argument parsing.
This lack of support makes the library unusable for most of the projects I had planned to use it in, and while that hurts me personally, I'm actually more worried about all the people who cant use software that uses this library for argument parsing because of the nonstandard syntax due to a disability that chains them to accessability tools that by default wont understand this non-standard syntax.
So respectfully, I feel like you are shooting yourself in the foot not supporting this, and I would formally like to ask that you support the standard syntax so that more people can actually use this.
The text was updated successfully, but these errors were encountered: