getopt_port
getopt_port copied to clipboard
Missing optional_argument support
Hey!
It looks like optional_argument
"has_arg
" flag is not yet implemented. Is this intentional? Will it come?
Thanks!
Interesting! I thought I'd implemented everything, but this must have slipped through.
Would you be willing to take a stab at it? I can't promise when I'll get around to it (if ever).
I've been trying to keep getopt_port compatible with as many other getopt implementation as possible (with BSD and GNU as the primary inspirations).
@apanloco Actually, I went to the test suite for verification, and I see at least a few optional_argument
tests. Can you be more specific as to what's not working?
I'll try to be more specific, but this is from memory since I've long moved passed this. (Was in a hurry, switched libs).
My app uses optional, required and positional arguments.
What I noticed was that when I used an optional requirement, followed by a required argument, followed by positional arguments, it stopped parse after the optional requirement and everything after the optional argument was put into positional arguments.
I.e. something like: --optional --required value positional
Everything including --required was put into positional.
It was something like this, but memory has already faded.
I then went on and did a search in the code for optional_argument and didn't find anything. I might have mistyped?
Thanks
Thank you. I can see how that case might be problematic.
And yes, I was also confused that there was no handling of optional_argument
, but it probably falls through for the normal cases -- the test suite at least proves it exists :)
I'll take a look at this when I find some time.
I added a test case for this in https://github.com/kimgr/getopt_port/pull/8, not sure if it reflects what you ran into originally (probably not!). Let's close this bug.